Problem Statement
Your engine lacks FULL OUTER JOIN. How can you emulate it, and what are the trade-offs?
Explanation
Union a LEFT JOIN and a RIGHT JOIN, and remove the overlap by filtering the right side of one branch to NULL. This yields all matches and non-matches from both inputs.
The trade-off is extra scan work and potential duplication risk if the filters are not precise. Indexes on join keys help both branches. Test the plan size on large tables to ensure it remains acceptable.
Code Solution
SolutionRead Only
SELECT a.*, b.* FROM A a LEFT JOIN B b ON b.k = a.k UNION ALL SELECT a.*, b.* FROM A a RIGHT JOIN B b ON b.k = a.k WHERE a.k IS NULL;
