Adding filter on the right side table on Left outer joins

user624558 picture user624558 · Jan 13, 2014 · Viewed 10.4k times · Source

On outer joins(lets take a left outer join in this case) how does adding a filter on the right side table work?

SELECT s.id, i.name FROM Student s 
LEFT OUTER JOIN Student_Instructor i
ON s.student_id=i.student_id
AND i.name='John'

I understand that if the filter was on the Student table it would be more like "Get all rows with name= John first and join the tables".

But I am not sure if that is the case if the filter is on the right side table(Student_Instructor). How does the filter i.name='John' gets interpreted?

Thank you

Answer

suf.agent picture suf.agent · Jan 13, 2014

Should be the same as:

SELECT s.id FROM Student s 
LEFT OUTER JOIN (Select * from Student_Instructor where name='John' ) i
ON s.student_id=i.student_id