SELECT city FROM a EXCEPT SELECT city FROM b; is run where both sides contain a NULL city. How are those NULLs treated?
Correct answer
D. They are treated as equal, so the NULL row is removed from the difference
16 views
D. They are treated as equal, so the NULL row is removed from the difference
16 views
Set operators use two-valued logic: unlike a comparison, EXCEPT and INTERSECT treat NULLs as equal to each other, so a NULL on the left that also appears on the right is removed. UNION likewise collapses duplicate NULL rows that a join would keep apart. This is exactly where EXCEPT behaves differently from NOT IN, which returns nothing when a NULL is present.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.