左连接

左连接

要求显示不是部门领导的所有员工。首先我们利用左连接将两个表连接起来,此时普通员工的部门信息会以null显示,用where对这些null进行筛选一下就可以了

select e.emp_no 
from employees as e left join dept_manager as d
on d.emp_no=e.emp_no 
where d.emp_no is null

not in+子查询

select emp_no
from employees
where emp_no not in (select emp_no from dept_manager);

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务