时间:2021-07-01 10:21:17 帮助过:7人阅读
SELECT
*
FROM
t_dept a
INNER JOIN t_emp b ON a.id = b.deptId;
SELECT
*
FROM
t_dept a
LEFT JOIN t_emp b ON a.id = b.deptId;
SELECT
*
FROM
t_dept a
RIGHT JOIN t_emp b ON a.id = b.deptId;
SELECT
*
FROM
t_dept a
LEFT JOIN t_emp b ON a.id = b.deptId
WHERE b.deptId IS NULL;
SELECT
*
FROM
t_dept a
RIGHT JOIN t_emp b ON a.id = b.deptId
WHERE a.id IS NULL;
SELECT
*
FROM
t_dept a
LEFT JOIN t_emp b ON a.id = b.deptId
UNION
SELECT
*
FROM
t_dept a
RIGHT JOIN t_emp b ON a.id = b.deptId;
SELECT
*
FROM
t_dept a
LEFT JOIN t_emp b ON a.id = b.deptId
WHERE b.deptId IS NULL
UNION
SELECT
*
FROM
t_dept a
RIGHT JOIN t_emp b ON a.id = b.deptId
WHERE a.id IS NULL;
MySQL 七种 JOIN
标签:select mysql union rom pre sele mys inner dep