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;
- A. 6 and 7
- B. 6 and 8
- C. 7 and 8
- 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
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2)…
- Table Enroll(sid, cid) rows: (1, 'C1'), (1, 'C2'), (2, 'C1'), (3, 'C1'), (3, 'C2'), (3, 'C3'), (4, 'C3'). Table Course(cid) rows: ('C1')…