EXISTS for faster membership
SQL
Easy
3 views
Problem Description
Find products that have at least one order item.
Sample Test Case
Input:
Products, OrderItems
Official Solution
SELECT p.product_id, p.name FROM Products p WHERE EXISTS (SELECT 1 FROM OrderItems oi WHERE oi.product_id = p.product_id);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!