zoukankan      html  css  js  c++  java
  • TOM上关于JOIN跟+号的讨论

    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:6585774577187

    to "predicate" on the parent table, you want to use a where clause - else by DEFINITION - every row in the parent table is coming out. If you: select ... from t1 left outer join t2 on (anything) / you get BY DEFINITION everything from t1, and if something matched the "on" clause - stuff from t2 will be there (if not, t2 is "made up")

    this whole thing is begining to remind me of the people who get mad at the results of this query:
    
    select * from emp where empno in ( select empno from dept );
    
    but anyway....
    
    you are NOT using a predicate.  if you were, i would agree with you.
    
    WHERE begins a predicate.  If you used a predicate, you observe the behaviour you seem to expect.
    
    ON is a join clause, a new thing in Oracle SQL with 9i.  It restricts the rows returned from EMP -- 
    not DEPT -- in the context of an outer join.
    
    You are just quite simply not understanding the syntax here.  ON != WHERE.  
    
    T1 left outer join T2 on ( any condition )
    
    will by the very very very definition of an ANSI outer join return ALL ROWS of T1 -- all of them -- 
    regardless of what "any condition" specifies since "any condition" is a join criteria for going 
    from T1 to T2 -- it is not a predicate, it does not restrict the rows being returned.
    
    
    The reason you never "got this before 9i" is because quite simply there was no syntax even 
    remotely similar to this with the ON clause.  It is new.  In 8i and before everything was in the 
    predicate.  Now, everything ISN'T in the predicate.
    
    Now however, you understand how it works.  So, you can code correct sql.
    
    The result set fits EXACTLY what you asked for -- you just didn't understand the semantics here.  
    
    and you know -- we don't "make up" this syntax.  it is sort of the way it was told to us that it 
    should be.  This is the ANSI outer join syntax, not the Oracle outer join syntax. 
  • 相关阅读:
    ui自动化-则神第一天04-学习方法
    PHP unserialize()
    路径中 斜杠/和反斜杠 的区别
    PhpStorm 克隆下来的项目改动,版本控制不起效果
    PhpStorm 回到上次编辑位置的快捷键
    mysql max_allowed_packet查询和修改
    PHP大批量插入数据库的3种方法和速度对比
    mysql5.7.23安装详细过程
    JS 放大镜
    aviary 图片编辑器
  • 原文地址:https://www.cnblogs.com/tracy/p/2043235.html
Copyright © 2011-2022 走看看