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);

Explanation

The database can stop at the first matching row. NOT EXISTS gives the opposite: users without orders.

Further reading

Problem with a question

Databases · Junior · question 74

Test yourself

Take the Databases · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz