Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Joining these two tables
Message
 
 
À
13/05/2010 15:52:12
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01464478
Message ID:
01464481
Vues:
91
This message has been marked as the solution to the initial question of the thread.
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform