select e.employee_id,e.last_name,d.department_name,l.city from employees e,departments d,locations l where e.department_id=d.department_id and d.location_id=l.location_id;
# 多表查询的分类用的是归纳式
# 角度一:等值链接 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 <=j.highest_sal;
# 角度二:自连接(自我引用) vs 非自连接
SELECT * from employees;
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;