Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using JOIN ON vs WHERE
Message
 
 
À
13/01/2009 15:02:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01373343
Message ID:
01373350
Vues:
26
You have to move any conditions that refer tables on the right side of a LEFT JOIN into appropriate ON clause, otherwise your LEFT JOIN will be killed by such conditions in the WHERE clause. Any conditions in the ON clause are evaluated before JOIN and any conditions in the WHERE clause are evaluated after JOINs.

>I have the following query
>SELECT fieldlist GROUP BY etc.;
>FROM PoItems ;
>        INNER JOIN PoMain ON pomain.ponum = poitems.ponum ;
>        INNER Join SupInfo On PoMain.UniqSupNo = SupInfo.UniqSupNo ;
>        INNER join Newfields ON newfields.uniq_key = PoItems.Uniq_key ;
>        LEFT Outer Join PoItSchd On PoItems.UniqLnNo = PoItSchd.UniqLnNo ;
>   WHERE PoItems.uniq_key = lcUniqKey AND Not EMPTY(PoItems.ponum) AND NOT poitems.lCancel;
>   HAVING cond
>
>I typically try to write my queries so that the JOIN parts only show the joining criteria and put selection criteria into WHERE
>
>In this case, would it be better to move any/all parts of the WHERE clause into the JOIN?
>
>In this case, execution speed is not really a consideration but I'm wondering if there is a potential difference in the result set.
>
>Thanks to all.........Rich
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform