-- 等值连接
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 非等值连接
-- 非等值连接
SELECT * FROM job_grades;
-- 举例名字,月薪和对应的等级
SELECT last_name,salary,grade_level
FROM employees e,job_grades j
WHERE e.salary BETWEEN j.lowest_sal AND j.highest_sal;
SELECT * FROM employees;
SELECT last_name,salary,grade_level
FROM employees e,job_grades j
WHERE e.salary >= j.lowest_sal AND e.salary<= j.highest_sal;
-- 角度2:自连接(自我引用)VS 非自我引用
-- 查询员工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;