Mysql中left join on and和left join on where 的区别
来源:互联网 发布:淘宝uv pv在哪里查看 编辑:程序博客网 时间:2024/05/21 19:28
最近在看别人写的代码时,看到了left join on and 的写法,刚开始以为他写错了,是不是少东西了,后来研究了一下,人家是对的,而且这种写法将作表的数据全部保留,有点孤陋寡闻,头一次遇到这种写法,记录下来吧。
LEFT JOIN ON WHERE:在临时表生成后,再对临时表的数据进行过滤,再返回左表。
LEFT JOIN ON AND:在临时表生成的过程时,ON中的条件不管是否为真,都将返回左表。
比如有一个用户表user
有一个成绩表score
想查询总分大于250分的信息
SELECT * FROM `user` a LEFT JOIN score b ON a.id = b.user_id AND total_score > 250
结果是
用where条件查询SELECT * FROM `user` a LEFT JOIN score b ON a.id = b.user_id WHERE total_score > 250
用and这种情况也比较多,比方说就是想统计满足条件的左边表的记录,就算为空,也要列出来,那这种方法就很好使用,否则还要在连接一次用户表。
阅读全文
0 0
- Mysql中left join on and和left join on where 的区别
- [转载]SQL语句中LEFT JOIN ON WHERE和LEFT JOIN ON AND的区别
- MySQL的left join中on与where的区别
- mysql 中left join on 与 where 的区别
- oracle中left join中on和where的区别
- oracle中left join中on和where的区别
- Oracle的left join中on和where的区别
- Oracle的left join中on和where的区别
- Oracle的left join中on和where的区别
- Oracle的left join中on和where的区别
- Oracle的left join中on和where的区别
- Oracle的left join中on和where的区别
- Oracle的left join中on和where的区别
- left join中on和where的区别是什么
- SQL Server: left join on 和 left join where区别
- mysql left join on and和left join on where 对比
- left join on ...and ... 与left join on ... where.. 的区别
- left join on and与left join on where的区别
- CentOS6上安装redis并配置服务自启动
- MTD(2)---nand flash的底层驱动代码分析
- 文件隐藏
- Root-NFS: Server returned error -13 while mounting /home
- 扛住100亿次请求?我们来试一试
- Mysql中left join on and和left join on where 的区别
- LINUX树状文件系统结构
- POJ3461 Oulipo KMP模板
- java 实现简单文本验证码思路源码
- POJ 刷题系列:2739. Sum of Consecutive Prime Numbers
- 383. Ransom Note
- 深入理解DIP、IoC、DI以及IoC容器
- 过滤器
- RIFF文件是什么