题解 | #使用含有关键字exists查找未分配具体部门的员工的所有信息。#

使用含有关键字exists查找未分配具体部门的员工的所有信息。

http://www.nowcoder.com/practice/c39cbfbd111a4d92b221acec1c7c1484

说一下具体思路:
本来想着用左连接来实现,结果发现exists没用到,哈哈!
后来发现dept_emp表中,如果这个员工没有被分配则不可能出现在dept_emp中,则exists就可以用到了!
select * from employees where not exists(
select emp_no from dept_emp where dept_emp.emp_no = employees.emp_no)
;

全部评论

相关推荐

FieldMatching:看成了猪头顾问,不好意思
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务