Databases · Junior · Question 74 of 75
What does EXISTS check?
SELECT name FROM users u
WHERE EXISTS (SELECT 1 FROM orders o WHERE o.user_id = u.id);- 1Whether the table
ordersexists - ✓Correct answer: Whether the subquery returns at least one row; here, users with at least one order
- 3Whether the column
user_idis not NULL
Explanation
The database can stop at the first matching row. NOT EXISTS gives the opposite: users without orders.