SQL self-joins Help Query

时间:2016-04-15 15:19:58

标签: mysql

How to display those employees who are working in the same dept where his manager in the below table:

enter image description here

?

1 个答案:

答案 0 :(得分:1)

使用self join即可。

select e1.*
from emp e1 inner join emp e2 
    on e1.mgr = e2.eno
where e1.dept_no = e2.dept_no