A LEFT JOIN carries the right-table condition b.status = 'active' in the WHERE clause instead of the ON clause. What is the effect?
A
Nothing changes, because the optimiser moves the predicate into the ON clause
B
All inactive matches are kept while unmatched rows are duplicated
C
The query fails because WHERE cannot reference the right table
D
Rows with no matching b row are removed, turning the outer join into an effective inner join
Correct answer
Correct answer
D. Rows with no matching b row are removed, turning the outer join into an effective inner join
13 views
⚔️
Challenge a friend on SQL for Data Analysis
Same MCQs, timed, live leaderboard. Send the link on WhatsApp – no sign-up needed.
Create challenge
Explanation
Outer join predicate placement matters: a WHERE predicate on the right table evaluates to UNKNOWN for unmatched rows and filters them out, so the outer join behaves like an inner join. Putting the condition in ON filters matches before the join, preserving left rows with NULL-extended columns. This is one of the most common SQL interview traps.
Reference
Asked in: NTS, PPSC IT, Interviews
Doubts & discussionNot sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ
‹ Previous MCQ Values 100, 100, 90 are ranked in descending order. What do RANK, DENSE_RANK and ROW_NUMBER produce? Next MCQ › What does WHERE col <> 'x' do with rows where col IS NULL?