Chris90
Chris90

Reputation: 1998

Filter order when joining two tables

I have query below that gives me the employee and mangagers for that employee based off a self join,

select e.name as employeename, m.name as managername
from employee e
left join employee m
on e.mgr_id = m.emp_id
where e.doj < m.doj

I know when left joining the first table being joined has to be filtered in the where clause and second in on, what would I do here since the filter contains both tables or in a different example where its not self joined and its joined on 2 different tables but the filter contains both tables? Thanks

Upvotes: 0

Views: 138

Answers (1)

trillion
trillion

Reputation: 1401

you could left join on e.doj < m.doj instead of using the where clause

Upvotes: 1

Related Questions