What happens to LEFT JOIN orders o ON ... WHERE o.status = 'paid' when o.status is NULL for unmatched rows?
Correct answer
D. The query behaves like an inner join, dropping unmatched orders
15 views
D. The query behaves like an inner join, dropping unmatched orders
15 views
A LEFT JOIN pads unmatched right-side columns with NULL, but the WHERE predicate then tests those NULLs and the comparison evaluates to unknown, so the rows are filtered out. The result is that the outer join silently becomes an inner join. To keep the outer semantics, put the condition in the ON clause, or allow NULL explicitly with o.status = 'paid' OR o.status IS NULL.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.