Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Left join proper syntax
Message
From
31/10/2000 08:08:26
 
 
To
31/10/2000 02:18:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00436236
Message ID:
00436276
Views:
15
>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.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform