SqlServer中关联表on和where后条件是否生效
2015-08-29 13:31
423 查看
环境:Sql Server2008.
inner join on后面跟的直接条件是有效的,同时and后面跟的条件也是有效的;
left/right join on后面跟的直接条件是有效的,但是and后面跟的条件无效的;
left/right join on可以通过where添加过滤条件,where后的条件都是有效的.
SELECT top 2 testDtil.* FROM testMain right join testDtil on testMain.joinhm = testDtil.joinhm and 1=2 ;
SELECT top 2 testDtil.* FROM testMain right join testDtil on testMain.joinhm = testDtil.joinhm where 1=2 ;
SELECT top 2 testDtil.* FROM testMain left join testDtil on testMain.joinhm = testDtil.joinhm and 1=2 ;
SELECT top 2 testDtil.* FROM testMain left join testDtil on testMain.joinhm = testDtil.joinhm where 1=2 ;
SELECT top 2 testDtil.* FROM testMain inner join testDtil on testMain.joinhm = testDtil.joinhm and 1=2 ;
SELECT top 2 testDtil.* FROM testMain inner join testDtil on testMain.joinhm = testDtil.joinhm where 1=2 ;
inner join on后面跟的直接条件是有效的,同时and后面跟的条件也是有效的;
left/right join on后面跟的直接条件是有效的,但是and后面跟的条件无效的;
left/right join on可以通过where添加过滤条件,where后的条件都是有效的.
SELECT top 2 testDtil.* FROM testMain right join testDtil on testMain.joinhm = testDtil.joinhm and 1=2 ;
SELECT top 2 testDtil.* FROM testMain right join testDtil on testMain.joinhm = testDtil.joinhm where 1=2 ;
SELECT top 2 testDtil.* FROM testMain left join testDtil on testMain.joinhm = testDtil.joinhm and 1=2 ;
SELECT top 2 testDtil.* FROM testMain left join testDtil on testMain.joinhm = testDtil.joinhm where 1=2 ;
SELECT top 2 testDtil.* FROM testMain inner join testDtil on testMain.joinhm = testDtil.joinhm and 1=2 ;
SELECT top 2 testDtil.* FROM testMain inner join testDtil on testMain.joinhm = testDtil.joinhm where 1=2 ;
相关文章推荐
- 一个基于redis和disque实现的轻量级异步任务执行器
- MySQL数据类型和常用字段属性总结
- MySQL开发规范与使用技巧总结
- MySQL数据库分片技术调研
- MySQL数据库分片技术调研
- Oracle(三)--> 其他数据库对象(简单扼要论序列)
- MySQL分页查询以及优化
- 在centOS中安装mongodb
- 浅谈Oracle数据库中的缓存-Cache (IO)
- 数据库三级模式介绍
- MySQL数据库编码格式问题
- 从Oracle迁移到Mysql之前必须知道的50件事
- 自定义数据库同步程序
- redis安装及简单操作
- postgresql 的自动增量字段
- Hibernate分页(sql和hql)两种方法
- MySQL导入大sql 文件大小限制问题的解决
- 新安装的mysql必须调整的10项配置
- Mysql导出表结构及表数据 mysqldump用法
- 数据库工具