且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在第二个表上具有过滤条件的Oracle外连接

更新时间:2023-10-23 14:28:46

否,没有条件下结果集会有所不同.

No, there is no condition under which the result sets will be different.

但是您的假设"a.id = b.id(+)没有意义"不是100%正确的.它具有含义,因为它定义了连接,否则将是a和b的笛卡尔积,其中所有行都来自a和b.name='XYZ'.

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'.

(+)无效,因为该语句在语义上"是错误的.在id上进行外部联接在名称上进行联接是没有意义的.

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.

通常需要这样的东西:

select  * from a,b where a.id =b.id(+) and b.name(+) = 'XYZ';

http://www.sqlfiddle.com/#!4/d19b4上的简短示例/15