When would you use a FULL OUTER JOIN?

Last updated 13 July 2026

Use a FULL OUTER JOIN when you need every row from both tables, matching where possible but keeping unmatched rows from either side with NULLs filling the gaps. It's the go-to for reconciliation: finding what exists on one side but not the other.

  • Semantics: Returns matched pairs plus unmatched left rows plus unmatched right rows: a union of LEFT and RIGHT join behavior.

  • Typical use cases:

    • Reconciliation: compare two datasets (e.g. source vs. target) to find records missing on either side.

    • Merging partial datasets where neither table is a strict superset of the other.

  • Finding mismatches: Filter with WHERE a.key IS NULL OR b.key IS NULL to isolate rows that failed to match on one side.

  • Caveat: Not supported natively in MySQL: emulate with a LEFT JOIN UNION a RIGHT JOIN.

[lang:sql] SELECT COALESCE(a.id, b.id) AS id, a.val, b.val FROM source a FULL OUTER JOIN target b ON a.id = b.id WHERE a.id IS NULL OR b.id IS NULL; -- rows present in only one side

  • https://medium.com/@krthiak/30-sql-window-functionion-questions-for-interviews-day-47-of-100-days-of-data-engineering-ai-and-638bef1af0f6
  • https://www.datacamp.com/blog/top-sql-interview-questions-and-answers-for-beginners-and-intermediate-practitioners
  • https://builder.ai2sql.io/blog/sql-window-functions-interview
  • https://medium.com/activated-thinker/top-20-sql-interview-questions-for-data-analyst-data-scientist-ml-engineers-688bd22bb139
  • https://datalemur.com/blog/sql-window-functions-interview-questions
  • https://thedataforge.medium.com/50-sql-interview-questions-every-data-engineer-must-know-advanced-edition-part-2-c6a5fe8dd18b
  • https://medium.com/towards-data-engineering/mastering-sql-recursive-ctes-key-concepts-and-interview-questions-04f69c408e81
  • https://code.likeagirl.io/cte-vs-subquery-vs-recursive-cte-the-interview-question-every-data-scientist-should-know-ce6163487841
  • https://www.youtube.com/watch?v=Hv54WLTHN70
  • https://leetcode.com/discuss/study-guide/1601295/database-sql-primer-part-4-recursive-ctes/
  • https://www.geeksforgeeks.org/sql-server/recursive-cte-in-sql-server/
  • https://www.datainterview.com/blog/top-100-sql-interview-questions
  • https://www.red-gate.com/simple-talk/databases/sql-server/t-sql-programming-sql-server/questions-about-cube-rollup-and-grouping-sets-that-you-were-too-shy-to-ask/
  • https://lolithasherley7.medium.com/sql-interview-questions-and-answers-0a51debd30e7
  • https://learnsql.com/blog/group-by-sql-interview-questions/
  • https://builder.ai2sql.io/blog/sql-aggregate-functions-interview
  • https://medium.com/@piyush.devspace/rollup-vs-cube-for-group-by-439dde93036e
  • https://stackoverflow.com/questions/28550679/what-is-the-difference-between-lateral-join-and-a-subquery-in-postgresql
  • https://www.baeldung.com/sql/lateral-join-vs-subquery
  • https://medium.com/@goldengrisha/a-deep-dive-into-sql-lateral-join-7b09fcb3b745
  • https://dba.stackexchange.com/questions/237219/when-to-use-lateral-joins-vs-correlated-subqueries-in-postgres
  • https://upesonline.ac.in/blog/advanced-sql-interview-questions
  • https://www.geeksforgeeks.org/sql/difference-between-nested-subquery-correlated-subquery-and-join-operation/
  • https://www.practicewindowfunctions.com/learn/gap_and_island
  • https://www.youtube.com/watch?v=18_cInZr0Gc
  • https://www.red-gate.com/simple-talk/databases/sql-server/t-sql-programming-sql-server/introduction-to-gaps-and-islands-analysis/
  • https://medium.com/@mvanshika23/sql-interview-patterns-you-must-know-part-1-n-gaps-and-islands-e9db5c97140f
  • https://medium.com/analytics-vidhya/sql-classic-problem-identifying-gaps-and-islands-across-overlapping-date-ranges-5681b5fcdb8
  • https://www.interviewbit.com/sql-interview-questions/
  • https://github.com/Devinterview-io/sql-interview-questions
  • https://www.tredence.com/blog/30-sql-interview-questions-2026
All Advanced SQL interview questions