CS FundamentalsModerateProduct-company MCQ pattern

Assertion (A): In SQL, `WHERE dept = NULL` returns no rows even when dept contains NULL values. Reason (R): A comparison with NULL using = evaluates to UNKNOWN, and WHERE keeps only rows for which the condition is TRUE.

  1. A. Both A and R are true, and R explains A
  2. B. Both A and R are true, but R does not explain A
  3. C. A is true, R is false
  4. D. A is false, R is true

Correct answer: A. Both A and R are true, and R explains A

NULL = NULL is UNKNOWN, not TRUE, so no row passes. The right test is dept IS NULL. GROUP BY, DISTINCT and set operators are the places where NULLs are treated as equal.

More DBMS and SQL questions

Exams that ask this topic