-- 查询公司是否有大于60岁的员工,有则输出
select * from emp3 where exists(select * from emp3 where age > 60);#错误写法,为全表输出
select * from emp3 a where exists(select * from emp3 b where a.age > 60);
select * from emp3 where eid in (select eid from emp3 where age > 60);#用in来实现
-- 查询有所属部门的员工信息
select * from emp3 a where exists (select * from dept3 b where a.dept_id = b.deptno);
select * from emp3 a where dept_id in(select deptno from dept3 );#用in来实现
注意exists的效率币in高