736. CASE order state — edge case 4

DBMS Published Updated 0 Views Verified
Write a MySQL query that handles NULL correctly. Avoid accidental three-valued-logic bugs.
Looking for the latest Sarkari Result 2026 updates? Check the latest government exam results, merit lists and result updates on Sarkari Resultess.
Sarkari Resultess
Questions & Answers

Answer & Explanation

4 Answers
Verified

Option A

Use NOT IN without considering NULLs in the subquery.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 1
Verified

Option B

Use column = NULL.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 2
Verified

Option C

Use COUNT(column) when you need to count NULL values too.
Additional Explanation
This option is incorrect for the stated requirement.
Sarkari Resultess
Editorial Answer 3
Verified Correct Answer

Option D

SELECT id,CASE WHEN status='completed' THEN 1 ELSE 0 END AS is_completed FROM orders;
Additional Explanation
Correct implementation. Prefer parameterized queries in application code, validate affected rows for UPDATE/DELETE, and use transactions for related writes.
Sarkari Resultess
Editorial Answer 4