SELECT employee_id,last_name,department_name,city
FROM employees e,departments d,locations l
WHERE e.department_id=d.department_id
and d.location_id=l.location_id;
#多表查询的分类用的是归纳式
/*
角度1:等值链接 vs 非等值链接
角度2:自连接(自我引用) vs 非自连接
角度3:内连接 vs 外连接
*/
#角度1:等值链接 vs 非等值链接
SELECT * from job_grades;
#查询姓名,月薪和对应的等级
SELECT e.last_name,e.salary,j.grade_level
from employees e,job_grades j
where e.salary BETWEEN j.lowest_sal AND j.highest_sal;
SELECT e.last_name,e.salary,j.grade_level
from employees e,job_grades j
where e.salary >= j.lowest_sal AND
e.salary<= highest_sal;
#角度2:自连接(自我引用) vs 非自连接
SELECT * from employees;
#查询员工的id,姓名,及其管理者的id和姓名
SELECT emp.employee_id,emp.last_name,mgr.employee_id,mgr.last_name
FROM employees emp,employees mgr
WHERE emp.manager_id = mgr.employee_id;