MySQL的join七种连接方式
左连接 left join
左连接 select * from table a left join table b on a.key = b.key
右连接
右连接 select * from table a right join table b on a.key = b.key
内连接
内连接 select * from table a inner join table b on a.key =b.key
以上三种连接是比较常用的连接,
a表独有
a表独有 select * from table a left join table b on a.key = b.key where b.key is null
b表独有
b表独有 select * from table a right join table b on a.key = b.key where a.key is null
全连接
全连接 select * from table a full outer join table b on a.key = b.key
a,b独有
a,b独有 select * from table a full outer join table b on a.key = b.key where a.key is null or b.key is null
第一次写笔记,主要是为了体验一把,以后继续努力。