标签:select mys from 结果 mysql sql name mysql 案例 sele
外连接:内连接结果+主表中有而从表没有的结果#案例:查询男朋友不在男神表的女神名
#左连接
SELECT
b.name
FROM
beauty b
LEFT OUTER JOIN
boys bo
ON
b.boyfriend_id=bo.id
WHERE
bo.`id` IS NULL;
#右连接
SELECT
b.name
FROM
boys bo
RIGHT OUTER JOIN
beauty b
ON
b.`boyfriend_id`=bo.`id`
WHERE
bo.id IS NULL;
#案例:查询哪个部门没有员工
SELECT
d.department_name
FROM
employees e
RIGHT OUTER JOIN
departments d
ON
e.`department_id`=d.`department_id`
WHERE
e.`department_id` IS NULL;
标签:select mys from 结果 mysql sql name mysql 案例 sele
原文地址:https://blog.51cto.com/14437184/2437918