Mysql-left join on后接and,和where的区别

一、left join on 中的 and 

当and和left join on结合,and语句并不会过滤掉行数。行数的多少取决于主表的行数,副表只是补充显示数据,没有的就显示空,加上where才会根据条件过滤掉行数。

1.对左表过滤

and的语句对左表过滤,无论条件真假,左表的数据依旧全部返回,left join的原则决定的

 

2.对右表过滤

and语句对右表过滤,左表的数据依旧全部返回

select * from A left join B 
on A.id = B.id  and B.name='FRDS'
where dfcs is null

  

posted @ 2024-09-16 13:23  南方的墙  阅读(295)  评论(0)    收藏  举报