SQL Joins, Explained Visually
The same two tables, four joins — see the SQL, the rows, and where the NULLs come from.
SELECT c.id, c.name, o.id, o.amount FROM customers c INNER JOIN orders o ON o.customer_id = c.id;
Only rows that match on BOTH sides. Dana (no orders) and order 103 (no customer) both vanish.
Result (3 rows)
| c.id | c.name | o.id | o.amount |
|---|---|---|---|
| 1 | Ava | 100 | 40 |
| 1 | Ava | 101 | 25 |
| 2 | Ben | 102 | 60 |
customers
| id | name |
|---|---|
| 1 | Ava |
| 2 | Ben |
| 3 | Cara |
| 4 | Dana |
orders
| id | customer_id | amount |
|---|---|---|
| 100 | 1 | 40 |
| 101 | 1 | 25 |
| 102 | 2 | 60 |
| 103 | 5 | 10 |
Runs entirely in your browser.
The one idea that makes joins click
A join is about which unmatched rows survive. INNER keeps only rows that match on both sides. LEFT keeps every left row and pads the missing right side with NULL. RIGHT does the mirror. FULL keeps everything from both. The data is identical — only the treatment of the rows that don't match changes.
Why NULLs appear (and the interview trap)
The NULLs in an outer join are the whole point — they mark rows with no match. The classic mistake is filtering on a right-table column in the WHERE clause of a LEFT JOIN, which silently turns it back into an INNER JOIN by dropping those NULL rows. Put such conditions in the ON clause instead.
A note on RIGHT and FULL
LEFT JOIN is far more common than RIGHT in real code — any RIGHT JOIN can be rewritten as a LEFT by swapping the tables, which most people find easier to read. Some databases (older SQLite included) don't support RIGHT/FULL at all, so knowing the LEFT equivalent is genuinely useful.
Other free tools
- SQL Formatter
- Resume ↔ Job Matcher
- A/B Test Calculator
- SQL Case Study Practice
- Descriptive Statistics Calculator
- Sample Size Calculator
- Correlation Calculator
- Percentage Change & CAGR Calculator
- JSON ⇄ CSV Converter
- CSV Cleaner & Viewer
- Regex Tester
- How to Become a Data Analyst
- How to Become an AI Analyst
- Data Analyst Interview Questions
- Analyst Skills Checklist
- Resume Bullet Builder
- Confidence Interval Calculator
- Excel Formulas Cheat Sheet
SQL is the core analyst skill
Data, business and product analyst roles, scraped daily from company career pages.
Browse analyst jobs