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. 
原文地址:https://www.cnblogs.com/tracy/p/2043235.html