-- Mysql分为外连接和内连接
-- 外连接有SQL92 和 SQL99
-- SQL92不能在Mysql中使用
-- SQL99内连接
SELECT employee_id,department_name
FROM employees e inner join departments d
on e.department_id=d.department_id;
SELECT employee_id,department_name,city
FROM employees e inner join departments d
on e.department_id=d.department_id
INNER JOIN locations l
on d.location_id=l.location_id;
-- SQL99外连接
-- 左连接
SELECT employee_id,department_name
FROM employees e left outer join departments d
on e.department_id=d.department_id;
SELECT employee_id,department_name
FROM employees e right outer join departments d
on e.department_id=d.department_id;