datarekha
SQL Easy Asked at AmazonAsked at GoogleAsked at Microsoft

What is the difference between INNER JOIN, LEFT OUTER JOIN, and FULL OUTER JOIN?

The short answer

INNER JOIN returns only rows where the join condition matches in both tables. LEFT OUTER JOIN returns every row from the left table plus matching rows from the right, filling NULLs where there is no match. FULL OUTER JOIN returns all rows from both sides, with NULLs wherever one side has no match.

How to think about it

The question sounds basic, but the interviewer is really watching whether you reason about row counts and NULLs — not whether you can recite three definitions. The strongest answers lead with a use case: “I’d reach for LEFT JOIN when I want all customers, whether or not they’ve ordered.”

Row behaviour at a glance

The whole family differs only in which unmatched rows survive:

Join typeRows kept from A (left)Rows kept from B (right)
INNERmatched onlymatched only
LEFT OUTERallmatched only
RIGHT OUTERmatched onlyall
FULL OUTERallall
INNERLEFTFULL OUTER
Shaded area = rows returned. INNER keeps only the overlap; LEFT keeps all of A; FULL OUTER keeps everything.

A worked example — INNER vs LEFT

Four customers, but Dana has placed no orders. INNER JOIN keeps only matched pairs, so Dana vanishes:

SELECT c.name, o.order_id, o.amount
FROM customers c
INNER JOIN orders o ON c.id = o.customer_id
ORDER BY c.name;
nameorder_idamount
Aarav101120
Aarav10280
Bea103200
Chen10450

Switch one word — INNER to LEFT — and Dana returns, padded with NULL where the right side has nothing to offer:

SELECT c.name, o.order_id, o.amount
FROM customers c
LEFT JOIN orders o ON c.id = o.customer_id
ORDER BY c.name;
nameorder_idamount
Aarav101120
Aarav10280
Bea103200
Chen10450
DanaNULLNULL

That extra Dana row — present in one result, absent in the other — is the difference between the join types. Everything else follows from “what happens to the unmatched rows.”

In an interview, mention

  • FULL OUTER JOIN isn’t supported in MySQL — emulate it with LEFT JOIN ... UNION ALL ... RIGHT JOIN ... WHERE left.id IS NULL.
  • RIGHT JOIN is just a LEFT JOIN with the tables swapped; most style guides prefer LEFT for readability.
  • Always reason aloud about what happens to unmatched rows — that habit is what separates strong candidates.
Learn it properly LEFT, RIGHT, FULL

Keep practising

All SQL questions

Explore further

Skip to content