Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting records from two different tables in one query
Message
De
15/03/2010 10:10:14
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01454516
Message ID:
01454533
Vues:
58
>There're at least 3 ways you can do that
>
>* 1 - EXISTS subquery
>SELECT * FROM mytable1 WHERE NOT EXISTS (SELECT 1 FROM mytable2 WHERE myfield1 = mytable1.myfield1)
>* 2 - JOIN
>SELECT mytable1.* FROM mytable1 JOIN mytable2 ON mytable2.myfield1 = mytable1.myfield1 ;
>  WHERE mytable2.myfield1 IS NULL
>* 3 - IN subquery
>SELECT * FROM mytable1 WHERE myfield1 NOT IN (SELECT myfield1 FROM mytable2)
>
>The second one most likely will be the fastest in VFP
>


Shouldn't #2 be a left join ?
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform