Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
3 table join
Message
 
 
À
15/02/2011 20:22:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01500313
Message ID:
01500319
Vues:
49
Would this work for you?
SELECT main.pk, main.date, main.desc, parts.pno, parts.pdesc, tools.tno, tools.tdesk
  FROM main
   LEFT JOIN parts ON parts.fk = main.pk
   LEFT JOIN tools ON tools.fk = parts.pk
>I have a set of three table I would like to join (I intend to produce a report and want to have only one source table for the report). Here is a mock-up of the three tables
>TABLE: MAIN
>PK   date     desc.......................etc.
>1     d1      desc1
>2     d2      desc2
>
>TABLE parts
>PK    FK     pno     pdesc
>1     1       p1     pdesc1
>2     1       p2     pdesc2
>3     2       p3     pdesc3
>
>TABLE tools
>PK     FK     tno     tdesc
>1       1      t1     tdesc1
>2       2      t1     tdesc1
>3       2      t2     tdesc2
>4       2      t3     tdesce
>
>I want the result to be
>PK     date     desc     pno     pdesc     tno     tdesc
>1       d1      desc1    p1      pdesc1    t1      tdesc1
>1       d1      desc1    p2      pdesc2
>2       d2      desc2    p3      pdesc2    t1      tdesc1
>2       d2      desc2                      t2      tdesc2
>2       d2      desc2                      t3      tdesc3
>
>Keeping in mind that this is VFP8..........
>
>I can, if necessary, get this result using xBase coding, but I'm hoping (even though I haven't figured it out) that there some SQL command (or sequence of commands) which could produce the desired result. (The repeated values for date and desc could be blank)
>
>Thanks for any and all suggestions...........Rich
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform