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_id | name |
|---|---|
| 101 | Ava |
| 102 | Ben |
| 103 | Cara |
| 104 | Dev |
loans
| loan_id | member_id | loan_date |
|---|---|---|
| 1 | 101 | 2026-01-12 |
| 2 | 103 | 2026-02-03 |
| 3 | 101 | 2026-03-20 |
| 4 | 102 | 2026-04-08 |
| 5 | 105(deleted) | 2026-05-14 |
query
SELECT members.name, loans.loan_date FROM members JOIN loans ON members.member_id = loans.member_id;
result: 4 rows
| name | loan_date |
|---|---|
| Ava | 2026-01-12 |
| Ava | 2026-03-20 |
| Ben | 2026-04-08 |
| Cara | 2026-02-03 |
Keeps only rows that match in both tables. Dev (no loans) and loan 5 (no member) are left out.
Which rows does each one keep?
| Join | Matched rows | Members with no loans | Loans with no member | Rows here |
|---|---|---|---|---|
| 4 | ||||
| 5 | ||||
| 5 | ||||
| 6 | ||||
| 1 | ||||
| 1 |
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 loanskeeps the same rows asloans 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.
The lessons behind this page
Know someone fighting with a spreadsheet? Send them this page.