Exists
EXISTS (subquery) is true if the subquery returns at least one row. SELECT name FROM students s WHERE EXISTS (SELECT 1 FROM marks m WHERE m.roll = s.roll AND m.score < 40); students who have at least one fail paper.
SELECT 1 inside is a habit — you only care that a row exists, not the columns. NOT EXISTS is ‘no matching child row’.
Often equivalent to a JOIN, but EXISTS stops at the first match. Nice for ‘is there any’.
Trap — EXISTS (SELECT * FROM marks) without linking to the outer row — true for everyone if marks is non-empty.
On the example next to this theory — Exists — uNION merges result sets and drops duplicate rows.
WHERE EXISTS (SELECT 1 FROM marks m WHERE m.roll = s.roll);