知识点
- 员工可能暂无部门内连接会剔除员工,因此使用左连接left join
- 当前to_date=
- 排除员工就是经理的情况!=
代码
select e.emp_no, m.emp_no from dept_emp as e
left join dept_manager as m
on e.dept_no = m.dept_no
where e.emp_no != m.emp_no
and e.to_date = '9999-01-01'
select e.emp_no, m.emp_no from dept_emp as e
left join dept_manager as m
on e.dept_no = m.dept_no
where e.emp_no != m.emp_no
and e.to_date = '9999-01-01'