Concept · Combining tables

OUTER JOIN

An outer join keeps rows that have no match and fills the missing side with NULL. LEFT, RIGHT and FULL say which sides are kept.

Before continuing: This entry is part of the JOIN guide. If you are new to the topic, start with JOIN.

OUTER JOIN example

The employees appears twice with different aliases. Carmen is kept even though her manager_id is NULL.

Result verified in SQLite
idemployeeowner
1Claire SmithNULL
3Beth MorganAlex Reed
6Ernest ColeCharles Page
Employees with or without a manager
SELECT e.id,
       e.name AS employee,
       r.name AS owner
FROM employees AS e
LEFT OUTER JOIN employees AS r
  ON r.id = e.manager_id
WHERE e.id IN (1, 3, 6)
ORDER BY e.id;

Check the result with small data

One person has a call recorded and the other does not.

Self-contained query · SQLite
WITH people(id, name) AS (
  VALUES (1,'Amy'), (2,'Liam')
), calls(person_id, date) AS (VALUES (1,'2026-10-10'))
SELECT p.name, l.date
FROM people p LEFT OUTER JOIN calls l ON l.person_id=p.id
ORDER BY p.id;
Query result
namedate
Amy2026-10-10
LiamNULL

LEFT OUTER JOIN and LEFT JOIN mean the same thing: both keep Amy and Liam. The word OUTER is optional here.

Check your understanding: Why does Liam still appear with a NULL date?

Show answer

Because LEFT JOIN keeps every person even when they have no match in calls. Since Liam has no calls, the columns from that table are filled with NULL.

What changes from case to case

TypeKeepsHow a missing match shows
LEFT JOINEvery row from the leftNULL in the right-hand columns
RIGHT JOINEvery row from the rightNULL in the left-hand columns
FULL JOINEvery row from both sidesNULL on the side with no match

Common mix-ups with OUTER JOIN

Treating OUTER as a statement in its own right

OUTER JOIN needs a direction. Write LEFT, RIGHT or FULL depending on which set must survive without a match.

Another common mistake is applying, in WHERE, a filter that rejects the NULL values created by the join, so it ends up behaving like an inner join.

Choosing which set must survive the join

Before choosing the direction, define what the report covers. “Every employee and their manager, if they have one” keeps employees. “Every manager and the people they manage” keeps managers, even those with no direct reports. The word OUTER does not choose that population: LEFT, RIGHT and FULL do.

Padded rows appear only when a row on the preserved side finds no match. If it finds two, you get two related rows, not an extra row of nulls. That is why an outer join does not guarantee one row per entity. When the report needs that unit, check the keys and summarise the detail to that level before combining.

To tell a missing relationship apart from unknown data, show a required key from the side that may be missing. A manager's name can be null on a row that did match, so it cannot detect a missing match. Then review the filters: a condition on the right table in WHERE can remove the row you wanted to keep. Describe each filter as either a matching rule or a final selection rule so you can put it in the right place.

Technical questions: PostgreSQL: Table Expressions and Joins (opens in a new tab).