CS FundamentalsHardProduct-company MCQ pattern

Table A(x) rows: (1), (1), (2), (NULL). Table B(x) rows: (1), (1), (1), (NULL), (3). How many rows do the inner join and the left join return?

Table A(x) rows: (1), (1), (2), (NULL). Table B(x) rows: (1), (1), (1), (NULL), (3). How many rows do the inner join and the left join return?
SELECT * FROM A JOIN B ON A.x = B.x;
SELECT * FROM A LEFT JOIN B ON A.x = B.x;
  1. A. 6 and 7
  2. B. 6 and 8
  3. C. 7 and 8
  4. D. 2 and 4

Correct answer: B. 6 and 8

Each of A's two 1s matches B's three 1s: 2 × 3 = 6; NULLs never match each other. The left join adds A's unmatched rows 2 and NULL: 6 + 2 = 8. Counting NULL = NULL as a match gives 7.

More DBMS and SQL questions

Exams that ask this topic