1 今天发现左连接的时候 on 后面加的条件不起作用,反复看了很多次,没看出来问题,Google了下,发现on后面加的条件只作为连接条件,不作为筛选作用
如果想实现筛选功能,需要继续在后面加上 where条件
例如 select * from user u left join class c on u.class_id=c.id where c.states is not null
这样的话,is not null 才会起筛选作用, u.class_id=c.id 起的是附表连接主表的对接条件作用
2018年11月27日18:02:49 cx
原文:https://www.cnblogs.com/blogsofmy/p/10028040.html