1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. Why does a WHERE clause such as WHERE bonus = NULL never…

Added 30 Nov -0001

Why does a WHERE clause such as WHERE bonus = NULL never return rows?

  1. NULL is a reserved keyword and causes a syntax error
  2. The column must be cast to text before comparison
  3. A comparison with NULL is unknown, never true Correct answer
  4. NULL is treated as zero in comparisons

Correct answer

C. A comparison with NULL is unknown, never true

15 views

MCQSEXAM

Explanation

SQL uses three-valued logic, and any comparison with NULL yields UNKNOWN, which WHERE treats as false, so = NULL filters out every row. The correct predicate is IS NULL or IS NOT NULL, and ifnull-style functions handle replacement values. The same rule explains why NOT IN (subquery containing a NULL) returns no rows: the comparison becomes UNKNOWN for every candidate.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs