Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem writing SQL with *ANSI nested structure*
Message
De
19/09/2000 13:59:33
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Problem writing SQL with *ANSI nested structure*
Divers
Thread ID:
00418176
Message ID:
00418176
Vues:
51
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform