Traps & Trick QuestionsMedium
Why does `NOT IN` with a NULL-containing subquery return zero rows?
Seen at: Amazon · LinkedIn · Stripe
You want users who haven’t placed any orders. You write:
SELECT id FROM users
WHERE id NOT IN (SELECT user_id FROM orders);
The query returns zero rows, even though you know dozens of users have no orders. What’s wrong?
Draft your answer
Saved to this browser only. Try it before you peek at the model answer.
Stuck? Peek at a hint
Reveals the model answer and the self-score rubric.