SQL · Question 14 · Hard

Table A has one column x with rows: 1, 1, 2, NULL Table B has one column x with rows: 1, 1, NULL, 3 What does this query return?

SELECT COUNT(*)
FROM A
JOIN B ON A.x = B.x;
  1. 2
  2. 5
  3. 6
  4. 4
Answer and explanation

Answer: D. 4

Explanation: Each of the two 1s in A matches each of the two 1s in B, giving 2 × 2 = 4 rows. The value 2 has no match, and NULL = NULL is not TRUE, so the NULLs do not join.

Previous: Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT… · Next: Table A has one column x with rows: 1, 1, 2, NULL Table B has one column x…

Practise sql

Try a fresh set of sql questions with an explanation after every answer, free and without signing up: SQL practice. Or sit a full placement mock test.

More sql questions

More technical & programming practice

Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps · GenAI Basics · Pseudo-code · C Programming · Java

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge