group by where条件的设置 | 您所在的位置:网站首页 › 出纳工作的主要内容总结怎么写 › group by where条件的设置 |
left join on 和where条件的放置
kanyun123: 因此on后的关联关系是用来生成临时表的条件,直到遇到终结符(如where) left join on 和where条件的放置kanyun123: 简单来说,on是用来设定连接条件的,对于left join来言,左表是一定全部查出的 如下SQL: [code=sql] select * from A a left join B b on a.id = b.id and a.id > 2 ; [/code] 上面SQL对A表的过滤是没有效果的,A表还是可以过滤出来。 当把上述SQL的and换成where后就可以对A表过滤了! [code=sql] select * from A a left join B b on a.id = b.id where a.id > 2 ; [/code] 那么on 就不能过滤了吗?显然不是的 [code=sql] select * from A a left join B b on a.id = b.id and b.id > 2 ; [/code] 上面SQL对B表做了过滤,但是查询了A表的全部数据。 如果把上面SQL的and 换成where 又会怎么样呢 [code=sql] select * from A a left join B b on a.id = b.id where b.id > 2 ; [/code] 此时 查询出来的数据A,B表数量相同 win10安装docker(适用于windows家庭版)一起玩编程: 迁移到的目标目录‘D:\docker\vm-data\DockerDesktop\’在你本机是否存在? win10安装docker(适用于windows家庭版)weixin_47342543: 请问wsl--erport拒绝访问是怎么回事 win10安装docker(适用于windows家庭版)Crazy-David: 适用于 x64 计算机的 WSL2 Linux 内核更新包 https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi |
CopyRight 2018-2019 实验室设备网 版权所有 |