Question

List the names of all customers who bought both envelopes and labels (either in the same order or different orders).please give me an sql query for this question and i have tables as follows customer(...

List the names of all customers who bought both envelopes and labels (either in the same order or different orders).please give me an sql query for this question and i have tables as follows customer(customer_name,address,zipcode,customer_id,state),office_supplies(item_name,item_id,cost,category),orders(order_id,date,customer_id) order_details(quantity,order_id,item_id)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer.)

The query to the above question is as follows :

--Selecting DISTINCT Customer Names as the name can repeat

-- Also, joining all the tables as we have a primary key and a foreign key in all the tables from which data needs to be filtered

SELECT DISTINCT CUSTOMER_NAME FROM CUSTOMER C, OFFICE_SUPPLIES OS, ORDERS O, ORDER_DETAILS OD

WHERE C.CUSTOMER_ID=O.CUSTOMER_ID

AND O.ORDER_ID = OD.ORDER_ID

AND OS.ITEM_ID = OD.ITEM_ID

WHERE OS.ITEM_NAME IN ('ENVELOPS','LABELS');

For any doubts, queries, drop a comment below.

Add a comment
Know the answer?
Add Answer to:
List the names of all customers who bought both envelopes and labels (either in the same order or different orders).please give me an sql query for this question and i have tables as follows customer(...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT