Mysql实现Oracle的 full join

在Oracle中, 除了inner join,left join,right join,还有

full join

SELECT column_name(s) FROM table_name1 FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_name

只要其中某个表存在匹配,FULL JOIN 关键字就会返回行

在Mysql中,是没有full join的,怎么去实现呢

左联 + 右联 + union

SELECT column_name(s) from table_name1 left join table_name2 on table_name1.column_name = table_name2.column_name 
union 
SELECT column_name(s) from table_name1 right join table_name2 on table_name1.column_name = table_name2.column_name
posted @ 2021-04-26 14:52  YC-L  阅读(19)  评论(0编辑  收藏  举报