SQL Joins and Set Operations Questions
Combining data across multiple tables using inner, outer, cross, and self joins, plus set operations (UNION, INTERSECT, EXCEPT). Covers join-key selection, fan-out and row-multiplication pitfalls, merge strategies, and integrating data from disparate sources. A high-frequency interview surface for anyone who queries relational data.
Explain what a RIGHT JOIN does, then rewrite a RIGHT JOIN query as an equivalent LEFT JOIN by swapping the table order. Why do many teams avoid RIGHT JOIN in their codebase even though it's standard SQL?
Write a query that performs a FULL OUTER JOIN of two same-shaped tables (say two systems' daily revenue figures) and produces one reconciled row per key with both sides' values, a delta, and a status column ('match' / 'mismatch' / 'only in left' / 'only in right'). Then explain how you'd emulate a FULL OUTER JOIN in a dialect that doesn't support it, and how the same pattern extends to reconciling three or more sources at once.
Rewrite this old-style comma-separated join (FROM a, b WHERE a.id = b.a_id AND ...) into explicit JOIN ... ON syntax, and explain the practical reasons explicit joins are preferred in production code, including what silently goes wrong if someone forgets a WHERE condition in the old style.
Same underlying question, three different tools: given two point-in-time snapshots of the same population, write it (a) as a LEFT JOIN anti-join, (b) as NOT EXISTS, and (c) using EXCEPT. Compare correctness (especially around NULLs and duplicate rows) and typical performance across these three, and say which you'd default to.
What does JOIN ... USING(column) do differently from JOIN ... ON a.column = b.column, particularly for the shared column in the result set and how you reference it afterward in SELECT or ORDER BY? Show a short example, and note where dialect support or behavior differs.
Unlock Full Question Bank
Get access to all 42 SQL Joins and Set Operations interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.