Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to join 3 tables
Message
De
21/10/2003 18:43:31
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
21/10/2003 18:35:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00840872
Message ID:
00840875
Vues:
22
>hello everybody
>
>i have 3 tables i need to join
>pnvendor
>inv
>vendor
>i am able to join the first 2 tables
>sele a.pn ;
>   from pnvendor a left join inv b on a.pn = b.pn ;
>   where ;
>      "1004" $ a.vendorid .and. ;
>      "04AV205" $ a.pn
>how do i add the 3rd table. the 3rd table (vendor) needs to be joint to the 1st table (pnvendor) on the vendorid field in the same way the 1st and the 2nd table are joint.
>
>thank for all your help as always!

That would be something like this:
sele a.pn ;
   from pnvendor a;
      left join inv b on a.pn = b.pn ;
      left join vendor on a.keyfield = vendor.keyfield;
   where ;
      "1004" $ a.vendorid .and. ;
      "04AV205" $ a.pn
If you need to join the SECOND table to the third, the syntax becomes a little more involved; you have to insert stuff between the JOIN and ON, thusly:
sele a.pn ;
   from pnvendor a;
      left join inv b;
         left join Table3 on b.KeyField = Table3.KeyField;
      on a.pn = b.pn ;
   where [SomeCondition]
Note that I alligned the first LEFT and the last ON, to indicate they go together.

HTH,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform