周柃君

2020-08-20   阅读量: 705

Mysql

子查询的相关操作符([not] in,any和all)

扫码加入数据分析学习群

image.png

例:

1.[not] in

查询员工数不少于5人的部门所有员工,显示empno,ename,sal,grade

select *from emp

where deptno in(select deptno from emp group by deptno having count(*)>=5);

2.ANY

查询基本工资高于30号部门任意员工的其他部门员工信息

select * from emp

where sal>any(select sal from emp where deptno=30) and deptno<>30;

3.ALL

查询基本工资高于30号部门所有员工的员工信息

select * from emp

where sal>all(select sal from emp where deptno=30);


29.9467 1 0 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子