The Cartesian product part is what trips people up.
Start by defining concrete sample tables with a common key column where one table has 3 rows and the other has 5 rows for that key. Then, for each join type, explain the matching logic and compute the result row count by multiplying the number of matching rows from each side (3×5=15 for INNER and LEFT, 5×3=15 for RIGHT). Finally, clarify that LEFT JOIN returns all rows from the left table plus unmatched right rows (but here all left rows match, so 15), RIGHT JOIN returns all rows from the right table plus unmatched left rows (15), and INNER JOIN returns only matches (15).
Pro tip: Mention that the row count is the product of matching rows, and explicitly state that if there were non-matching rows, the counts would differ; this shows you understand the nuance beyond the simple case.
Create two small tables (e.g., Orders and OrderDetails) with a shared key column where one table has 3 rows with key 'A' and the other has 5 rows with key 'A'. This makes the explanation tangible.
Describe that INNER JOIN returns only rows where the key matches in both tables. Since all 3 left rows match all 5 right rows, the result is 3×5 = 15 rows.
Explain that LEFT JOIN returns all rows from the left table plus matching rows from the right. Here, all left rows have matches, so the result is still 3×5 = 15 rows (no NULLs added).
Explain that RIGHT JOIN returns all rows from the right table plus matching rows from the left. Since all right rows have matches, the result is 5×3 = 15 rows (no NULLs added).
Conclude that in this specific case, all three joins produce 15 rows because every row on both sides has a match. Highlight that the row count is the Cartesian product of matching rows, and mention how non-matching rows would change the counts.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.