Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Query
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00667468
Message ID:
00667492
Views:
21
This message has been marked as the solution to the initial question of the thread.
>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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform