Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 USING MULTIPLE TABLES

Author  Topic 

dlmagers10
Starting Member

48 Posts

Posted - 2010-10-22 : 12:03:08
SELECT ORDER_NUM, ORDER_DATE
FROM ORDERS
WHERE EXISTS
(SELECT *
FROM ORDER_LINE
WHERE ORDERS.ORDER_NUM = ORDER_LINE.ORDER_NUM
AND PART_NUM = 'DR93')
AND EXISTS
(SELECT *
FROM CUSTOMER
WHERE CUSTOMER.CUSTOMER_NUM = ORDERS.CUSTOMER_NUM
AND CUSTOMER_NUM ='608');

orders table = order_num, order_date, customer_num

order_line = order_num, part_num, num_ordered, quoted_price

customer table = customer_num, customer_name

Need to figure out each order that was placed by Johnson's Department Store and that contains an order_line for a Gas Range (part_num DR93);

IN RESULTS: I am just getting something like just the column titles

ORDER_NUM | ORDER_DATE

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-23 : 01:47:03
that means there are no data in ORDERS table satisfying the other conditions.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -