What are EXISTS and NOT EXISTS and how do they differ from IN?
This question compares boolean checks against set membership. It tests optimization and NULL handling.
Why Interviewers Ask This
EXISTS is often more efficient and handles NULLs better than IN. Interviewers check if you know the semantic differences and performance characteristics.
How to Answer This Question
Explain EXISTS checks for row existence (boolean). Contrast with IN which compares values. Highlight NULL sensitivity of NOT IN. Mention stopping at first match.
Key Points to Cover
- EXISTS returns boolean
- Stops at first match
- NOT IN is NULL-sensitive
- Performance differences
Sample Answer
EXISTS checks if a correlated subquery returns at least one row, returning a boolean and stopping at the first match. IN compares a value against a list. EXISTS is robust with NULLs, whereas NOT IN can return unknown if…
Common Mistakes to Avoid
- Ignoring NULL behavior in NOT IN
- Thinking IN is always faster
- Confusing with JOIN logic
Sound confident on this question in 5 minutes
Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.