Difference between ON and WHERE clauses in SQL table joins

后端 未结 5 1436
小蘑菇
小蘑菇 2020-12-30 14:10
select e.last_name, e.hire_date
from employees e join employees m
on (m.last_name = \'Davies\')
and (e.hire_date > m.hire_date);

select e.last_name, e.hire_date
         


        
5条回答
  •  轮回少年
    2020-12-30 14:46

    The difference lies in when the engine performs the filtering. A "where" represents a filter on the computed product of both tables. The "on" keyword specifies how a join is performed. They are not semantically equivalent even if sometimes they both produce the same outcome.

    Cheers

提交回复
热议问题