Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
JOINing 3 tables
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00168360
Message ID:
00168364
Views:
31
>I used the query designer to create the following SELECT statement...
>
>SELECT A.account, A.namekey, A.department,;
>A.section, A.team, A.name, A.addr1_1,;
>A.addr1_2, A.city1, A.state1, A.zip1_5,;
>A.camt0, A.camt1, B.eamt0, B.eamt1,;
>B.gemp0, B.gemp1, B.temp0, B.temp1,;
>C.cproj, C.eproj, 0000000 AS cpcproj, ;
>0000000 AS epcproj;
>FROM A LEFT OUTER JOIN B;
>LEFT OUTER JOIN C ;
>ON A.account = C.account ;
>ON A.account = B.account;
>WHERE A.department NOT IN ("16","17","18","19","20");
>ORDER BY A.account;
>INTO TABLE vic
>
>...I need all records from A, and matching records in B and in C. I get all A records just fine, and their matching B records. But, every record in the result set has an identical value in the two C fields (C.cproj, C.eproj). I expected the LEFT OUTER JOIN to get the results I wanted, but why are the C values the same in every record (they are definitely different in the C table.
>
>Thanks!!!

Mark, you may try this syntax:

SELECT A.account, A.namekey, A.department,;
A.section, A.team, A.name, A.addr1_1,;
A.addr1_2, A.city1, A.state1, A.zip1_5,;
A.camt0, A.camt1, B.eamt0, B.eamt1,;
B.gemp0, B.gemp1, B.temp0, B.temp1,;
C.cproj, C.eproj, 0000000 AS cpcproj, ;
0000000 AS epcproj;
FROM A ;
LEFT OUTER JOIN B;
ON A.account = B.account;
LEFT OUTER JOIN C ;
ON A.account = C.account ;
WHERE A.department NOT IN ("16","17","18","19","20");
ORDER BY A.account;
INTO TABLE vic
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform