Predict INNER 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 INNER JOIN?
Code
SELECT COUNT(*) FROM A INNER JOIN B ON A.id = B.a_id;
Hint
INNER JOIN returns only matching rows.
Explanation
INNER JOIN returns only rows that match in both tables. Since all 3 rows in B match rows in A, the result has 3 rows.
Related Resources
Related Lessons
- Joins
Learn INNER 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.