0

for example, I have a sql query:

 select table1.*, table2.* from table1 
 left join table2 on table1.id=table2.id AND table2.someCol>123 (put it here)<p>
 where table2.someCol>123 (or put it here)

it seems that the two position all can put the filter condition, and is the SAME meaning, is it?

Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
lovespring
  • 19,051
  • 42
  • 103
  • 153

1 Answers1

5

No, it's not the same. It matters when you are left/right joining. If you put a where condition in the where clause referencing a left or right joined table, you basically turn it into an inner join. It would be a left or right join again, if you add OR referenced_left_or_right_joined_column IS NULL.

fancyPants
  • 50,732
  • 33
  • 89
  • 96