left join on 后and 和 where 的区别

Posted 冠军33

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了left join on 后and 和 where 的区别相关的知识,希望对你有一定的参考价值。

SELECT * FROM student a LEFT JOIN sc b ON a.Sid = b.Sid AND a.Sname="赵雷"

结果:(left join 左连接,左表所有数据 拼接 右表符合on条件的数据。on后用and连接,‘a.Sid = b.Sid AND a.Sname="赵雷"’都作为on条件)


SELECT * FROM student a LEFT JOIN sc b ON a.Sid = b.Sid WHERE a.Sname="赵雷"

结果:(当on后用where连接,where作为筛选条件,筛选‘student a LEFT JOIN sc b ON a.Sid = b.Sid’的结果集)

 

以上是关于left join on 后and 和 where 的区别的主要内容,如果未能解决你的问题,请参考以下文章

left join中,on字段后用and和where的性能区别

left join中,on字段后用and和where的性能区别

LEFT JOIN ON AND 和LEFT JOIN ON WHERE区别

left join on and 和left join on where 的区别

SQL语句中 LEFT JOIN 后 ON 和 WHERE 的区别

SQL语句中 LEFT JOIN 后 ON 和 WHERE 的区别