Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Query
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00667468
Message ID:
00667687
Vues:
16
That worked great, I was approaching the wrong way. Thank you very much!

>>I'm trying to get a query to work out, but no luck this should be easy.
>>
>>The Setup: Customer, Summary, Detail Tables (Basic Invoice DB Setup)
>>Customer -> Summary via cust_id, summary -> detail via order_num
>>
>>The Query: Print customers that have ordered a product that starts with 'SE', but never ordered a product that starts with 'RC' or 'ST'. The product or part # is in the detail database.
>>
>>Is such a query possible with SQL? Thanks!
>
>Try
SELECT * FROM Customer ;
>  WHERE cust_id IN ( ;
>       SELECT cust_id FROM summary
>          JOIN detail ON summary.order_num = detail.order_num ;
>               AND part_num LIKE "SE%") ;
>    AND cust_id NOT IN ( ;
>       SELECT cust_id FROM summary
>          JOIN detail ON summary.order_num = detail.order_num ;
>               AND (part_num LIKE "RC%" OR part_num LIKE "ST%")) ;
>
Marvin Masson
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform