>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%")) ;
--sb--