Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to join 3 tables
Message
From
21/10/2003 19:45:07
 
 
To
21/10/2003 19:25:19
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00840872
Message ID:
00840899
Views:
18
>>I mean you don't have to nest them. This works the same, and is easier to read.
>>
>>sele a.pn ;
>>   from pnvendor a;
>>      left join inv b on a.pn = b.pn ;
>>      left join Table3 on b.KeyField = Table3.KeyField ;
>>   where [SomeCondition]
>>
>
>This will join tables 1 and 2, and tables 1 and 3.
>
>My second example joined tables 1 and 2, and tables 2 and 3.

Actually, it does join 1 and 2, 2 and 3 : pnvendor [a] to inv [b] and inv [b] to table3.
This is another reason why I recommend not using single character aliases [readability again] :)

>
>I belive it is not always possible to re-arrange the order of the tables, especially when joining many tables. However, I would recommend joining a few pieces at a time - not for readability, but for speed.

I know that nesting joins (join..join..on..on) can lead to problems if you are joining 1 to 2 then 1 to 3, because the joined table will not be "seen" - so you have to do it sequentially join..on...join...on. I actually started doing all joins sequentially because I ran into this nested issue with the view designer back in vfp3 doing a 1 to 2 and 1 to 3 join; changing the joins from nested to sequential cured the problems with this type of join and worked no differently than nested for other joins. [ changing the joins also ended my relationship with the view designer :) ]
Insanity: Doing the same thing over and over and expecting different results.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform