Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Left join proper syntax
Message
From
31/10/2000 03:23:18
 
 
To
31/10/2000 02:18:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00436236
Message ID:
00436242
Views:
24
Michel,

Your last SELECT had a typo ("CHILD ON" missing) but it works. It produces the same result as Andrew's solution except that instead of the placeholder values for parent records that have no children, you get .null. values.

SELECT PARENT.ID,CHILD.ID FROM PARENT LEFT JOIN CHILD ON PARENT.ID=CHILD.PARENTID WHERE CHILD.MYFIELD=0

HTH

<
By using a standard SQL like the following, we obtain all combinations of parent/child records.

SELECT PARENT.ID,CHILD.ID FROM PARENT INNER JOIN PARENT.ID=CHILD.PARENTID

If we use a LEFT JOIN, we would end up with all all combinations of parent/child records + those parents which do not have a child record.

SELECT PARENT.ID,CHILD.ID FROM PARENT LEFT JOIN PARENT.ID=CHILD.PARENTID

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?>>
Daniel
Previous
Reply
Map
View

Click here to load this message in the networking platform