Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which statement is 'Better'
Message
De
09/09/2005 18:05:45
 
 
À
09/09/2005 17:47:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6
Divers
Thread ID:
01048319
Message ID:
01048322
Vues:
28
IMO, the JOIN is easier to read and maintain.

>Is it better to use a JOIN or a SUBSELECT if either will produce the correct result?
>
>For example
>SELECT DISTINCT pol.agentcode,pol.ctrl_num,pol.incep_date FROM frpolicy pol;
>  JOIN frlocat loc ON pol.agentcode=loc.agentcode and pol.ctrl_num=loc.ctrl_num;
>  WHERE pol.incep_date >={8/31/2005} AND loc.state='OR'
>
>
>SELECT pol.agentcode,pol.ctrl_num,pol.incep_date FROM frpolicy pol;
> WHERE EXISTS (SELECT * FROM frlocat loc;
>                WHERE loc.agentcode=pol.agentcode
>                  AND loc.ctrl_num=pol.ctrl_num;
>                  AND loc.state="OR")
>   AND pol.incep_date >= {8/1/2005}
>
>
>produce identical results in approximately the same time.
>
>Is it a matter of style or is there a reason to use one rather than the other?
>
>Thanks......
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform