使用的SQL大概是这样的:

select * from A left join B on A.id=B.id and A.id>10; --错误的使用

我们期望的结果集应该是 A中的id>10,但是实际上A.id>10 这个限制条件并没有起作用。

应该改成如下的这种形式:

select * from A left join B on A.id=B.id where A.id>10;--正确的使用

这是在oracle的官方文档中找到的相关说明:

left outer join
The result of a left outer join for table A and B contains all records of the left table A,
even if the join condition does not match a record in the right table B. For example, if
you perform a left outer join of employees (left) to departments (right), and if some
employees are not in a department, then the query returns rows from employees
with no matches in departments.

这是在 《Database System Concepts》这本书中找到的相关说明:

The right outer join is symmetric with the left outer join: It pads tuples
from the right relation that did not match any from the left relation with nulls and
adds them to the result of the natural join. In Figure 6.18, tuple (58583, null, null,
null, null, Califieri, History, 62000), is such a tuple. Thus, all information from the
right relation is present in the result of the right outer join.

大致的意思是,left join的结果集一定会包含左边表的所有记录。同理,right join一定会包含右边表的所有记录。

所以,使用时应该只在on子句中包含关联条件,单独对某个表的限制应该放到where子句中。

只是不知道,如果在left join的on子句中单独限制右边的表会不会有利于减少中间表的大小。

关于在left join的on子句中限制左边表的取值时出现非期望的结果的更多相关文章

  1. pdm 中怎么修改表的Name值时使Code值不变

    修改方法:PowerDesign中的选项菜单里修改,在[Tool]-->[General Options]->[Dialog]->[Operating modes]->[Nam ...

  2. jQuery中设置form表单中action值与js有什么不同。。。。

    jQuery中设置form表单中action值与js有什么不同.... HTML代码如下: <form action="" method="post" i ...

  3. springMVC 返回类型选择 以及 SpringMVC中model,modelMap.request,session取值顺序

    springMVC 返回类型选择 以及 SpringMVC中model,modelMap.request,session取值顺序 http://www.360doc.com/content/14/03 ...

  4. 关于readdir返回值中struct dirent.d_type的取值有关问题(转)

    关于readdir返回值中struct dirent.d_type的取值问题 原网页链接 http://www.gnu.org/software/libc/manual/html_node/Direc ...

  5. jQuery中设置form表单中action值的方法

    jQuery中设置form表单中action值的方法 (2011-03-17 10:18:19) 转载▼ 标签: 杂谈   html代码: <form id="myFormId&quo ...

  6. java中int,float,long,double取值范围,内存泄露

    java中int,float,long,double取值范围是多少? 写道 public class TestOutOfBound { public static void main(String[] ...

  7. Mybatis映射文件中#取值时指定参数相关规则

    Mybatis映射文件中#取值时指定参数相关规则 在#{}中,除了需要的数值外,还可以规定参数的一些其他规则. 例如:javaType,jdbcType,mode(存储过程),numericScale ...

  8. C语言中 指针、引用和取值

    指针是一个存储计算机内存地址的变量.从指针指向的内存读取数据称作指针的取值.指针可以指向某些具体类型的变量地址,例如int.long和double.指针也可以是void类型.NULL指针和未初始化指针 ...

  9. C#中hashtable的赋值、取值、遍历、排序操作

    一,哈希表(Hashtable)简述 在.NET Framework中,Hashtable是System.Collections命名空间提供的一个容器,用于处理和表现类似key/value的键值对,其 ...

随机推荐

  1. 利用React实现表头维度功能

    这是我真正意义上地用react实现一些东西.这次分享的是一个很简单的小组件,效果图先放上来: 前端样式用的是一套框架.功能很简单,就是根据选择的维度,在成员里选择对应这个维度的选项. 首先初始化一些数 ...

  2. java并发编程(六)Runnable和Thread实现多线程的区别

    http://blog.csdn.net/ns_code/article/details/17161237

  3. [转载] Win7KB3146706补丁导致蓝屏0x0000006B的修复方案

    进入winpe,将附件的蓝屏6B修复补丁kb3146706.zip的补丁替换windows/system32下面的ci.dll文件,里面有64和32位系统的,替换了文件就可以进入系统了. 启动进入系统 ...

  4. alfresco category searches...

    From page 475 of the Alfresco Developer Guide- Category searches use the PATH field, but you constru ...

  5. 利用jQuery对插件进行扩展时,方法$.extend()、$.fn.extend()区别与联系

      利用JQ开发插件的方法: 1.jQuery.extend(); 2.jQuery.fn.extend(); 3.通过$.widget()应用jQuery UI的部件工厂方式创建. 由于第三种方式通 ...

  6. GIT远程仓库地址变更

    将VS2013的解决方案添加到GIT源代码管理后会增加.gitattributes和.gitignore 2个文件以及.git目录 设置远程地址的文件在.git目录下的config文件中 直接修改上图 ...

  7. pixelmator处理png图片,处理掉过白的留白。

    作为一个CTO,还是得学会一些普通的修图技术的.这不,刚学会在pixelmator下如何处理png中过多的留白. 汗,其实就是一个菜单选项而已./image/trim canvas 效果如下:

  8. weblogic启动受管服务器报错Authentication for user weblogic denied (weblogic 11g 域账号密码不生效的解决方法)

    或者   解决方法:

  9. LeetCode Design Hit Counter

    原题链接在这里:https://leetcode.com/problems/design-hit-counter/. 题目: Design a hit counter which counts the ...

  10. oracle not in,not exists,minus 数据量大的时候的性能问题

    http://blog.csdn.net/greenappple/article/details/7073349/ 耗时 minus<not exists<not in