Predict LEFT JOIN Rows
Predict Output Medium
Question
Table A has 5 rows, table B has 3 rows. All B rows match A rows. How many rows from LEFT JOIN?
Code
SELECT COUNT(*) FROM A LEFT JOIN B ON A.id = B.a_id;
Hint
LEFT JOIN keeps all rows from the left table.
Explanation
LEFT JOIN returns all rows from the left table (A), with NULL for non-matching right rows. Since A has 5 rows, the result has 5 rows (2 with NULL for B's columns).
Related Resources
Related Lessons
- Joins
Learn LEFT JOIN.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.