子查询在一个select中出现多个嵌套查询语句 1.在where子句中使用子查询(一般返回"单行单列" "单行多列" "多行单列"(可以提供in.any.all )) 示例1:查找低于平均工资的雇员信息(返回单行单列) select * from emp where sal < (select avg(sal) from emp) 示例2:查找出公司最早雇佣的雇员信息(返回单行单列) select * from emp where hire…
分组查询 写的顺序: select...from...where... group by...having...order by... 执行顺序: from...where...group by.... having ... select ...order by .... 实例练习: -- existes : 用它来找寻满足一个条件的信息 -- 找寻多表中存在关联关系或不存在关联关系的数据 --查询部门当中没有员工的部门 select d.* from dept d where not EXIS…
--子查询 --子查询返回一个值 --查询出工资和scott一样的员工信息 select * from emp where sal in (select sal from emp where ename = 'SCOTT'); --子查询返回一个集合 --查询出工资和10号部门任意员工一样的员工信息 select * from emp where sal in (); --子查询返回一张表 --查询出每个部门最低工资.最低工资姓名.该员工所在部门名称 --1.先查询出每个部门最低工资 selec…