4 min read
•Question 1 of 29mediumWhat is the difference between INNER JOIN and OUTER JOIN?
Understanding SQL JOIN types.
What You'll Learn
- JOIN types explained
- When to use each
- Visual examples
JOIN Types
| Type | Returns |
|---|---|
| INNER JOIN | Only matching rows from both tables |
| LEFT OUTER JOIN | All from left + matching from right |
| RIGHT OUTER JOIN | All from right + matching from left |
| FULL OUTER JOIN | All rows from both tables |
Example
query.sqlSQL
-- INNER JOIN
SELECT * FROM users u
INNER JOIN orders o ON u.id = o.user_id;
-- LEFT JOIN (includes users without orders)
SELECT * FROM users u
LEFT JOIN orders o ON u.id = o.user_id;