Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proper Join Syntax
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00184398
Message ID:
00184413
Vues:
15
>How does VFP optimize a query when using join clauses?
>
>I have to get data from 2 children tables. The link is via the parent.
>
>Parent : SoHeader has customer ship to # and SoNo and CustNo
>Child1 : SoTrans has what was ordered, and SoNo
>Child2 : CustAddr has Customer ship to address.
>
>I need to get $s and # of units totals from SOTrans, and group them by each ship to location.
>
>So do you start at the parent, or a child in the SQL when using joins?
>
>TIA
>
select field list ;
   FROM Parent ;
      LEFT OUTER JOIN Child1 ;
        ON Parent.KeyID = Child1.ForeignKeyId ;
      LEFT OUTER JOIN Child2 ;
        ON Parent.KeyID = Child2.ForeignKeyId ;
   WHERE whatever_filter_criteria_goes_here ;
   GROUP BY _goes_here ;
   ORDER BY _goes_here
The LEFT OUTER JOIN gets all parent records even if it has no child records in either table. You also can not do this in the View designer. The view designer will nest the joins which will give an error later on. You can use the designer to get the initial SQL code to copy-and-paste into a PRG for editing and tweeking [and for documentation in case of disaster].
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform