Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which statement is 'Better'
Message
De
09/09/2005 18:57:55
 
 
À
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:
01048328
Vues:
24
>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......

If DISTINCT is necessary, then:
The second it is formally (in relational algebra) more correct,
infact the second can to be very more faster ( best case ) but little slower ( worst case )
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform