1021mysql 全外连接

mysql 不支持全外连接,那么使用union all进行替换

-- 其他数据库

SELECT * FROM aa a
FULL OUTER JOIN bb b 
ON a.col1=b.col1
AND a.col2=b.col2
AND a.col3=b.col3
AND a.col4=b.col4
AND a.col5=b.col5
AND a.col6=b.col6
WHERE a.col1 IS NULL OR b.col1 IS NULL

-- mysql数据库替换方法
SELECT COUNT(col1) FROM
(
SELECT a.* FROM aa a
LEFT JOIN bb b
ON a.col1=b.col1
AND a.col2=b.col2
AND a.col3=b.col3
AND a.col4=b.col4
AND a.col5=b.col5
AND a.col6=b.col6 WHERE b.col1 IS NULL
UNION ALL
SELECT c.* FROM aa a
RIGHT JOIN bb c
ON a.col1=c.col1
AND a.col2=c.col2
AND a.col3=c.col3
AND a.col4=c.col4
AND a.col5=c.col5
AND a.col6=c.col6
WHERE a.col1 IS NULL
) AS t

1021mysql 全外连接

上一篇:页面路由跳转地址-get方式


下一篇:iOS项目开发中的知识点与问题收集整理②