left join和inner join的区别
举例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 |
总结:内连接是把关联数据显示出来
左连接左边数据全部显示,右边显示匹配数据,无匹配NULL
右连接右边数据全部显示,左边显示匹配数据,无匹配NULL
喜欢请赞赏一下啦^_^
微信赞赏
![](https://images.cnblogs.com/cnblogs_com/ljf-Sky/1807277/o_200716012544%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200716092510.jpg)
支付宝赞赏
![](https://images.cnblogs.com/cnblogs_com/ljf-Sky/1807277/o_200716012531%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200716092459.jpg)