A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

SQL: OUTER JOINs (LEFT, RIGHT, FULL)

College Depth 72 in the knowledge graph I know this Set as goal
333prerequisites beneath it
See this on the map →
SQL Joins
SQL LEFT JOIN RIGHT JOIN FULL OUTER JOIN

Core Idea

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.

How It's Best Learned

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).

Explainer

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.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesSet Operations: Union, Intersection, and ComplementRelational AlgebraSQL: SELECT Statement and Basic QueriesSQL JoinsSQL: OUTER JOINs (LEFT, RIGHT, FULL)

Longest path: 73 steps · 333 total prerequisite topics

Prerequisites (1)

Leads To (0)

No topics depend on this one yet.