Customers Who Bought All Products
Medium
Subqueries
Return the customer_id of every customer who has bought every product listed in the Products table.
Table schema
Products(id INT PRIMARY KEY)
Purchases(customer_id INT, product_id INT)Sample data
Products: 1, 2, 3
Purchases:
customer_id | product_id
1 | 1
1 | 2
1 | 3
1 | 1
2 | 1
2 | 2
3 | 3
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.