RECAP

Every JOIN side by side

The same two tables, joined every way. Dev has never borrowed a book, and loan 5 belongs to a member whose record was deleted, so each join keeps a different set of rows. Pick a card to see it below.

JOIN (INNER) keeps only the rows that match in both tables.

members

member_idname
101Ava
102Ben
103Cara
104Dev

loans

loan_idmember_idloan_date
11012026-01-12
21032026-02-03
31012026-03-20
41022026-04-08
5105(deleted)2026-05-14
membersloans

query

SELECT members.name, loans.loan_date
FROM members JOIN loans
  ON members.member_id = loans.member_id;

result: 4 rows

nameloan_date
Ava2026-01-12
Ava2026-03-20
Ben2026-04-08
Cara2026-02-03

Keeps only rows that match in both tables. Dev (no loans) and loan 5 (no member) are left out.

Compare

Which rows does each one keep?

JoinMatched rowsMembers with no loansLoans with no memberRows here
4
5
5
6
1
1
Good to know

Things people mix up

  • JOIN is INNER JOIN. The word INNER is optional; both keep only matched rows. It is not a RIGHT JOIN.
  • RIGHT JOIN is LEFT JOIN backwards. members RIGHT JOIN loans keeps the same rows as loans LEFT JOIN members, so most people only write LEFT.
  • A Venn diagram shows which rows, not how many. Ava has two loans, so she appears twice in every join that keeps her.
  • "Only" joins are a LEFT or RIGHT JOIN plus IS NULL. Test a column that's never empty on the other side, such as its id.
  • Not every database has FULL JOIN. MySQL doesn't: combine a LEFT and a RIGHT JOIN with UNION.
  • In Excel, a lookup is a LEFT JOIN (your whole list, #N/A where nothing matched). Lookup & Merge's "Only matches" is INNER, and "Show what's missing" is the "only" joins.
Practise

The lessons behind this page

Know someone fighting with a spreadsheet? Send them this page.