Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Left join proper syntax
Message
De
31/10/2000 11:41:57
 
 
À
31/10/2000 08:08:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00436236
Message ID:
00436389
Vues:
18
>>Now, I would like to keep this ability of having those parent records which do not have a child record when we have to add a condition for the child record. Basically, I would need something like this:
>>
>>SELECT PARENT.ID,CHILD.ID FROM PARENT LEFT JOIN PARENT.ID=CHILD.PARENTID WHERE CHILD.MYFIELD=0
>>
>>However, this doesn't work because all parent records who do not have a child record do not meet that condition so they won't be listed in. How can I achieve that?
>
>In this situation, where the filter affects the child of an outer join, you need to add the filter condition to the join clause. That way, it's used in determining which records have a match and, therefore, which records come into the result because of the outer join. Here's the query you need:
>
>SELECT PARENT.ID,CHILD.ID ;
> FROM PARENT ;
> LEFT JOIN PARENT.ID=CHILD.PARENTID AND CHILD.MYFIELD=0
>
>When the filter condition is on the parent, you can leave it in the WHERE clause.

Thanks a lot, this works great.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform