时间:2021-07-01 10:21:17 帮助过:24人阅读
#案例:查询男朋友不在男神表的女神名
#左连接
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;
mysql sql99语法 外连接
标签:select mys from 结果 mysql sql name mysql 案例 sele