列子查询;返回的结果是一列(可以是多行)
常用的操作符:in,not in,any,some,all
代码:
-- 查询销售部和总部的所有员工信息
select * from emp where dept_id in (select id from dept where name='销售部' or name='总部');
-- 查询比研发部所有人工资都高的员工信息
select * from emp where salary>all(select salary from emp where dept_id=(select id from dept where name='研发部'));
-- 查询比研发部任意一人工资高的员工
select * from emp where salary>any(select salary from emp where dept_id=(select id from dept where name='研发部'));