1、全外连接
SELECT j.job_id,e.`employee_id`
FROM employees e
FULL OUTER JOIN jobs j ON e.`job_id`=j.`job_id`
2、自连接
案例:查询员工名字和上级领导的名字
SELECT e.last_name,m.last_name
FROM employees e
INNER JOIN employees m ON e.`manager_id`=m.employee_id;
SELECT e.last_name,m.last_name
FROM employees e,employees m WHERE e.`manager_id`=m.employee_id;
网友评论