MySQL数据库操作(第3章)
发布时间
阅读量:
阅读量
目录
复杂查询
子查询(嵌套查询)
关联关系(了解)
1. 一对一:
2. 一对多:
3. 多对多:
关联查询
- 笛卡尔积
关联查询的查询方式有三种:
关联查询总结:
复杂查询
子查询(嵌套查询)
1. 查询工资高于平均工资的员工信息
select avg(sal) from emp; 2147
select * from emp where sal>(select avg(sal) from emp);
2. 查询工资最高的员工信息
select max(sal) from emp;
select * from emp where sal=(select max(sal) from emp);
3. 查询工资高于2号部门平均工资的员工信息
select * from emp where sal>(select avg(sal) from emp where deptno=2);
4. 查询和孙悟空相同工作的其它员工信息
Retrieve all records from the emp table where the job title matches the result of a subquery and excludes employees with the name '孙悟
全部评论 (0)
还没有任何评论哟~
