Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem writing SQL with *ANSI nested structure*
Message
From
19/09/2000 13:59:33
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Problem writing SQL with *ANSI nested structure*
Miscellaneous
Thread ID:
00418176
Message ID:
00418176
Views:
53
I have three tables - an Employee table, a Vegies table that holds the employee ID and their favorite vegetable and a Fruits table that holdes the employee ID and their favorite fruit.

Employee 1 has a record in both Fruits and Vegies
Employee 2 has a record in Fruits only
Employee 3 has a record in Vegies only

I have no problem with writing the SQL *sequential style* as follows:

SELECT e.id, e.fname, e.lname, v.vegetable, f.fruit ;
FROM employee e ;
LEFT OUTER JOIN vegies v on e.id = v.id ;
LEFT OUTER JOIN fruits f on e.id = f.id ;

The result has all three employees with a value for vegetable, fruit or both. My problem is trying to write it in ANSI style or trying to duplicate the above result in the Query Builder. I don't get the same result for Employee 3 who has a record in Vegies - the result for him is NULL in the vegetable column.

SELECT Employee.*, Fruits.fruit, Vegies.vegetable;
FROM employee LEFT OUTER JOIN fruits;
LEFT OUTER JOIN vegies ;
ON Fruits.id = Vegies.id ;
ON Employee.id = Fruits.id

What am I doing wrong?
TIA
Ernest
Next
Reply
Map
View

Click here to load this message in the networking platform