问题
Is there any condition under which the result sets will be different from the following two statements?
select * from a,b where a.id = b.id and b.name = 'XYZ'
select * from a,b where a.id =b.id(+) and b.name = 'XYZ'
I think in both cases it will bring the common rows from a and b where b.name = 'XYZ'
. So a.id = b.id(+)
has no meaning.
回答1:
No, there is no condition under which the result sets will be different.
But your assumption "a.id = b.id(+)
has no meaning" is not 100% correct. It has a meaning, because it defines the join, otherwise this would be a cartesian product of a and b with all rows from a and b.name = 'XYZ'.
What has no effect is the (+)
, because the statement is "semantically" wrong. It makes no sense to outer join on id but to join on name.
Usually something like that is wanted:
select * from a,b where a.id =b.id(+) and b.name(+) = 'XYZ';
Short example at http://www.sqlfiddle.com/#!4/d19b4/15
来源:https://stackoverflow.com/questions/11568425/oracle-outer-join-with-filter-condition-on-the-second-table