摘要: 相关子查询: 即在查询中除了用到子查询外,还用到了表之间的连接(即多表查询) 以下有几个例子: 1 #18.查询各部门中工资比本部门平均工资高的员工的员工号, 姓名和工资(相关子查询) 2 select employee_id ,last_name ,salary 3 from employees 阅读全文
posted @ 2022-03-23 19:21 jue1e0 阅读(74) 评论(0) 推荐(0)
摘要: 1.exists和not exists的本质是判断存在或不存在一个元组,所以判断是否存在的值都是 select * 2.用到exists或是not exists都用到了跨表查询,所以一定要附上连接条件 示例: #15. 查询部门的部门号,其中不包括job_id是"ST_CLERK"的部门号 #正确写 阅读全文
posted @ 2022-03-23 19:13 jue1e0 阅读(151) 评论(0) 推荐(0)
摘要: 1.对以下例子进行分析: #查询平均工资最低的部门信息和该部门的平均工资(相关子查询) select d.*,(select avg(salary) from employees e2 where d.department_id = e2.department_id ) "avg_sal" from 阅读全文
posted @ 2022-03-23 11:09 jue1e0 阅读(57) 评论(0) 推荐(0)