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

Mysql实现Oracle的 full join

上一篇:Windows下MySQL8.0数据目录迁移


下一篇:YCSB测试MongoDB