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

南方的墙 / 2024-09-18 / 原文

SQL中and 和 where的筛选

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

加上where才会根据条件过滤掉行数

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