Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
(natural?) join question
Message
From
01/02/1999 13:39:13
 
 
To
01/02/1999 13:32:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00182610
Message ID:
00182620
Views:
9
>Using VFP 5.0a on WinNT 4.0 sp3.
>
>I want to do a select statement on two (or possibly more) tables where the results are based on an equal condition of a field from each table.
>
>If I do a "select * from a, b where a.id = b.id" I will get the desired result except that I'll get two fields named a.id_a and b.id_b, but no field named a.id or b.id.
>
>One way to do this would be to list all the desired fields in the output, but this list is very long and there is a limit (I think the list is limited by number of chacters), it is prone to errors, and just plain nasty looking.
>
>I think that what I am describing is a natural join, but I am not finding anything on natural join or the reference to the SELECT - SQL command.
>
>I do not care if I get a field named something like a.id_X or b.id_X, but I would like to guarantee a field named a.id (or tablename.id). Is there an easy way to do this?
>
>TIA,
>Marc Mandel

If you join tables having fields with the same name and you want to guarantee output field names then you should use AS clause:
Select a.id as aid, b.id as bid .... From a,b Where ....
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform