LEFT OUTER JOIN includes all rows from the left table and matching rows from the right table (nulls for non-matches). RIGHT OUTER JOIN is the opposite. FULL OUTER JOIN includes all rows from both tables. Outer joins are essential when relationships are optional.
Compare results of INNER vs LEFT JOIN on the same query to understand what rows are included/excluded. Practice scenarios where entities have optional relationships (e.g., employees who may not have assigned projects).
You already know that an INNER JOIN combines rows from two tables where a match exists on the join condition — and silently drops any row from either side that has no match. Outer joins solve the problem of those disappearing rows. In real-world data, relationships are often optional: not every customer has placed an order, not every employee has a manager, not every product has been reviewed. An INNER JOIN on customers and orders would simply omit customers who have never ordered, which might be exactly the population you need to analyze.
A LEFT OUTER JOIN (usually written simply as LEFT JOIN) preserves every row from the left table regardless of whether a match exists in the right table. When there is no match, the right table's columns are filled with NULL. Think of it as the left table saying "I'm all showing up — and if I happen to have a partner in the right table, great, bring them along; if not, I'll sit with empty seats." So `SELECT c.name, o.order_date FROM customers c LEFT JOIN orders o ON c.id = o.customer_id` returns every customer: those with orders show their order dates, and those without orders show NULL for order_date. This is the most commonly used outer join in practice.
A RIGHT OUTER JOIN is the mirror image — it preserves all rows from the right table and fills NULLs for unmatched left-side columns. In practice, most developers rewrite RIGHT JOINs as LEFT JOINs by swapping the table order, since reading left-to-right feels more natural. A FULL OUTER JOIN preserves all rows from both tables: rows with matches are combined normally, rows from the left with no right match get NULLs on the right side, and rows from the right with no left match get NULLs on the left side. FULL OUTER JOIN is useful for reconciliation tasks — comparing two datasets to find what exists in one but not the other.
A common pattern with outer joins is using NULL checks to find *non-matching* rows specifically. `SELECT c.name FROM customers c LEFT JOIN orders o ON c.id = o.customer_id WHERE o.id IS NULL` returns only customers who have *never* placed an order — the LEFT JOIN preserves them, and the WHERE clause filters to just the unmatched ones. This "anti-join" pattern is one of the most practical uses of outer joins and appears constantly in data analysis and reporting. Understanding when NULLs appear in your results — and whether they represent missing data or simply non-matching joins — is the key skill that outer joins demand.
No topics depend on this one yet.