Databases · Junior · Question 22 of 75
What does a LEFT JOIN return?
SELECT u.name, o.id
FROM users u
LEFT JOIN orders o ON o.user_id = u.id;- 1Only orders that have no user
- 2Only users who have orders
- ✓Correct answer: Every user; for users without orders the order columns are NULL
Explanation
A LEFT JOIN keeps all rows from the left table. RIGHT JOIN does the same for the right table, and FULL JOIN keeps unmatched rows from both.