Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT to combine master and 2 child tables
Message
De
11/05/2004 00:51:46
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00902663
Message ID:
00902693
Vues:
16
Will doing INNER JOINs work when the two child tables will have differnt number or records? For 1 qn_head record, there may be 5 qn_dtl records, and 3 qn_inv records. When I tried doing joins in SQL Server, it got confused and summed the wrong number of rows. I'll try it and see what I get. I'll let you know. :)

-----
Lee Perkins

>You're correct in that VFP doesn't support sub-queries of this type. (I think VFP 9 will, but that won't be out for a while.) Here's how you need to do this:
>
>SELECT h.pid_owner, h.ord_cod, ;
>       SUM(d.itm_prcus * d.qty_ord) as OrderTotal, ;
>       SUM(i.itm_prcus * i.qty_sent) as InvoiceTotal ;
>   FROM C:\QN\datatmp\qn_head h ;
>      INNER JOIN C:\qn\datatemp\qn_dtl d ;
>         ON d.pid_owner = h.pid_owner AND d.ord_cod = h.ord_code ;
>      INNER JOIN c:\qn\datatemp\qn_inv i ;
>         ON i.pid_owner = h.pid_owner AND i.ord_code = h.ord_cod ;
>   ORDER BY h.pid_owner, h.ord_cod
>
-----
Lee Perkins
TigerBase Technologies

"Lee is one that would plug his brain into the internet, if he could, and STILL scream for more" - Very good friend of Lee's
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform