2025-06-28•Abyan Dimas
SQL Joins Visualized: Inner, Left, Right, and Full
Joins are the heart of SQL. They let you combine data from multiple tables.
1. INNER JOIN (Intersection)
Returns records that have matching values in both tables.
- "Show me users who have placed an order."
SELECT * FROM users
INNER JOIN orders ON users.id = orders.user_id;
2. LEFT JOIN (Preserve Left)
Returns all records from the left table, and the matched records from the right table.
- "Show me all users, and their orders if they have any."
SELECT * FROM users
LEFT JOIN orders ON users.id = orders.user_id;
(Users with no orders will have NULL in order columns).
3. RIGHT JOIN (Preserve Right)
Opposite of Left Join. Rarely used.
4. FULL OUTER JOIN (Union)
Returns all records when there is a match in either left or right table.
- "Show me all users and all orders, acting as one big list."
Mastering JOINs is step one to mastering SQL.