What is the difference between putting a condition in ON and in WHERE for a LEFT JOIN?
Model answer
A condition on the right table in WHERE removes the NULL rows, turning the LEFT JOIN into an inner join effectively. Putting it in ON filters the right table while keeping all left rows. This is a common source of bugs and interview questions.
Learn this topic
SQL JOINs: INNER JOIN and LEFT JOIN Explained in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.