Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL that list all recs from 1 table without match in 2nd
Message
De
08/09/2000 16:50:40
 
 
À
08/09/2000 16:46:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00414411
Message ID:
00414420
Vues:
23
>>For simple explanation....
>>
>>I have two tables with these fields:
>>
>>MASTER
>>cname = char
>>
>>DETAIL
>>cname = char (match above cname)
>>dorder = date
>>
>>I need to create a list of all the MASTER records that DO NOT have a matching record in the detail.
>>I believe this should be a simple SQL select but I can't figure out how to get the joins / where clause
>>to work right so that I only get the MASTER records.
>>
>>HELP!!! Something simple and it's driving me nuts!!!
>
>Couple ways:
>

Sorry - you did give structures <g>
SELECT * ;
  FROM master ;
  WHERE cname NOT IN ;
  (SELECT cname FROM detail) ;
  INTO CURSOR cuNoMatch

or

SELECT * ;
  FROM master ;
  WHERE NOT EXISTS ;
  (SELECT * FROM detail WHERE detail.cname = master.cname) ;
  INTO CURSOR cuNoMatch
Insanity: Doing the same thing over and over and expecting different results.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform