1 左连接(以左表为主取数据左表没有的取null)
select * from a_table a left join b_table b on a.a_id = b.b_id;
2 右连接(以右表为主取数据左表没有的取null)
select * from a_table a right join b_table b on a.a_id = b.b_id;
3内连接(取并集)
select * from a_table a inner join b_table b on a.a_id = b.b_id;
4全连接(取A表和B表数据,不去重)
select a.id,a.name from a_table a union all select b.id,b.name from b_table b;
5全连接(取A表和B表数据,去重)
select a.id,a.name from a_table a union select b.id,b.name from b_table b;
图解: