原创

SQL-where on条件区别-放在where后影响主表(总体)条数,放在on后面影响子表条数-非inner join的条件,最好写在on后

left join edu_train_implement i on i.assoc_plan_id = a.id and i.is_delete = 0
条件放在where后影响主表(总体)条数,放在on后面影响子表条数

select * from ent_kemaihuagonggufenyou_datapool_jifenguize g
inner join ent_kemaihuagonggufenyou_datapool_jifenzhibiao z on g.zhibiaoshibiema = z.zhibiaoshibiema
left join ent_kemaihuagonggufenyou_datapool_jifenzhibiaoyingsheg y on y.zhibiaoshibiema = z.zhibiaoshibiema and y.`disable` <> 1 where g.`disable` <> 1 and z.`disable` <> 1 order by g.id desc
对于非inner join的条件,最好写在on后如果在where后实际就变成了inner join了,如果非inner join的表没有关联的数据,就查不到了
正文到此结束
本文目录