SQL 3) - 表连结 查找各个部门当前领导当前薪水详情以及其对应部门编号
查找当前薪水详情以及部门编号dept_no
http://www.nowcoder.com/questionTerminal/c63c5b54d86e4c6d880e4834bfd70c3b
方法)连结salaries & dept_manager
SELECT dm.emp_no, s.salary, s.from_date, s.to_date, dm.dept_no FROM salaries AS s JOIN dept_manager AS dm -- 表连结 ON s.emp_no = dm.emp_no WHERE dm.to_date ='9999-01-01' -- 限制条件(当前) AND s.to_date ='9999-01-01' ORDER BY s.emp_no ASC;解题要点:
- 题目限制条件 -- 当前(dept_manager.to_date='9999-01-01')领导 & 当前(salaries.to_date='9999-01-01')薪水详情
-
WHERE dm.to_date ='9999-01-01' AND s.to_date ='9999-01-01'
- 联立条件ON
ON s.emp_no = dm.emp_no