举例a、b表:
bId | bNum |
1 | 20 |
2 | 30 |
aId | aNum |
1 | 10 |
2 | 20 |
3 | 30 |
left join以左表为准
select * from a left join b on a.aId=b.bId;
aId | aNum | bId | bNum |
1 | 10 | 1 | 20 |
2 | 20 | 2 | 30 |
3 | 30 | NULL | NULL |
inner join 选两张表都有的,一一相等的
aId | aNum | bId | bNum |
1 | 10 | 1 | 20 |
2 | 20 | 2 | 30 |