-
本题比较简单,就是两个表的联合查询
-
题目中的隐藏条件:当前领导的薪水详情, 也就是说表中也保存的有过去领导的信息,这点一定要注意
-
参考答案
select s.emp_no,s.salary,s.from_date,s.to_date,d.dept_no
from salaries s,dept_manager d
where s.emp_no = d.emp_no
and s.to_date = '9999-01-01'
and d.to_date = '9999-01-01'
order by s.emp_no
- 知识拓展
a. select s.*,d.*
from salaries s,dept_manager d
where s.emp_no = d.emp_no
b. select s.*,d.*
from salaries s left join dept_manager d
on s.emp_no = d.emp_no
1.上面两种表的联合查询有区别吗,对查询效率有影响吗?
- 多表联合查询中join,left join,right join,inner join ,out join的含义和用法是什么?,什么时候用left join,什么时候用right join呢?选择不同的连接方式对查询效率是否有影响呢?