Jerry,
Move your where condition into JOIN condition otherwise your LEFT JOIN is transformed into INNER JOIN.
SELECT * ;
FROM parts LEFT OUTER JOIN price
ON parts.itemno = price.itemno
AND price.branchplant = '123'
AND price.date1 <= ldDate and price.date2 >= ldDate
INTO CURSOR myResults NOFILTER
Please read this blog
Why LEFT JOIN doesn't bring all records from the LEFT table? for explanation of the problem.
>I have a VFP9 app that needs to join these two tables. One is a part table and the other is a price table. They are related by part number. However some parts do not have an entry in the price table but I want all records from the parts table. Also, there is an effective date in the price table.
>
>I tried the following but I don't get the records from parts.dbf included in my results that have no entry in price.dbf.
>
>
>SELECT * ;
> FROM parts LEFT OUTER JOIN price
> ON parts.itemno = price.itemno
> WHERE price.branchplant = '123'
> AND price.date1 <= ldDate and price.date2 >= ldDate
> INTO CURSOR myResults NOFILTER
>
>
>How do I include all parts.dbf records in the results?
>
>Thanks,
>
>Jerry
If it's not broken, fix it until it is.
My Blog