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

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

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

exists / not exists : 存在/不存在,即将外表(employees表)的字段(emp_no)代入子查询(内表)中看是否成立/不成立。

select a.emp_no,a.birth_date,a.first_name,a.last_name,a.gender,a.hire_date
from employees a 
where not exists 
(select emp_no from dept_emp b where b.emp_no = a.emp_no);

直接外联结

select a.emp_no,a.birth_date,a.first_name,a.last_name,a.gender,a.hire_date
from employees a left join dept_emp b 
on a.emp_no = b.emp_no 
where b.dept_no is null;
全部评论

相关推荐

05-28 16:06
门头沟学院 Java
嵐jlu:我是山川🐔里🐔🧱的,阿里系简历全过; 你这简历一看就还是半成品啊,没有荣誉经历奖项什么的吗?
投递阿里巴巴集团等公司10个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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