left join on 和where条件的放置
对于left join,不管on后面跟什么条件,左表的数据全部查出来,因此要想过滤需把条件放到where后面
1
2
3
|
select
*
from
test2
left
join
test1
on
test2.id = test1.id
where
test2.id <>6
and
test1.id<>3;
|
on、where、having的区别
参考:
http://blog.youkuaiyun.com/muxiaoshan/article/details/7617533
本文转自许琴 51CTO博客,原文链接:http://blog.51cto.com/xuqin/1567852,如需转载请自行联系原作者