一图了解JOIN

 左下角获取A表加B表的数据,mysql数据库不支持 full outer join,mysql下可以这么写:

select * from tableA A left join tableB B on A.key=B.key 
union
select * from tableA A right join tableB B on A.key=B.key 

右下角获取A表独有的加B表独有的,mysql数据库不支持 full outer join,mysql下可以这么写:

select * from tableA A left join tableB B on A.key=B.key where B.key is null
union
select * from tableA A right join tableB B on A.key=B.key where A.key is null

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章