select .. from a,c where a.aa(+)=c.cc union select .. from a,b where a.aa(+)=b.bb
依你的意思还与c连接干啥,直接 select aa from a union all select bb from b 不就可以了吗!
select a.a1,a.a2,a.a3,b.b1,b.b2,b.b3,c.c1 from a,b,c where a.id=c.id
select tab1.*,tab2.*,tab3.* from tab1,tab2,tab3 where tab1.id=tab3.id(+) and tab2.id=tab3.id(+) 可保证表1和表2的所有记录被显示,表3仅为满足条件的记录被显示。
问题已经解决了,用了union,速度比较慢,还有谁能够提供更好的方案? 在此感谢Fred_Mark(我心飞扬) 给我的灵感. to BlueskyWide(谈趣者):你的根本不行,首先没有三个表连接,其次不能查出A,B表中所包含的所有记录.
to BlueskyWide(谈趣者):你的第二个回答出现如下错误: ORA-01417: 表可以外部连接到至多一个其它表.
select tab1.*,tab2.*,tab3.* from tab1,tab2,tab3 where tab1.id=tab3.id(+) or tab2.id=tab3.id(+)
to BlueskyWide(谈趣者) :如下也不行 select tab1.*,tab2.*,tab3.* from tab1,tab2,tab3 where tab1.id=tab3.id(+) or tab2.id=tab3.id(+) 出现错误 ORA-01719: OR 或 in操作数中不允许外部连接运算符(+)
try again:select tab1.*,tab3.* from tab1,tab3 where tab1.id=tab3.id(+) union select tab2.*,tab3.* from tab2,tab3 where tab2.id=tab3.id(+)
我已经说了这个可以 select tab1.*,tab3.* from tab1,tab3 where tab1.id=tab3.id(+) and tab1.id=tab2.id union select tab2.*,tab3.* from tab2,tab3 where tab2.id=tab3.id(+) and tab1.id=tab2.id 只是想要一种更快的方案
union
select .. from a,b where a.aa(+)=b.bb
select aa from a
union all
select bb from b
不就可以了吗!
可保证表1和表2的所有记录被显示,表3仅为满足条件的记录被显示。
在此感谢Fred_Mark(我心飞扬) 给我的灵感.
to BlueskyWide(谈趣者):你的根本不行,首先没有三个表连接,其次不能查出A,B表中所包含的所有记录.
ORA-01417: 表可以外部连接到至多一个其它表.
select tab1.*,tab2.*,tab3.* from tab1,tab2,tab3 where tab1.id=tab3.id(+) or tab2.id=tab3.id(+)
出现错误
ORA-01719: OR 或 in操作数中不允许外部连接运算符(+)
union
select tab2.*,tab3.* from tab2,tab3 where tab2.id=tab3.id(+)
select tab1.*,tab3.* from tab1,tab3 where tab1.id=tab3.id(+) and tab1.id=tab2.id
union
select tab2.*,tab3.* from tab2,tab3 where tab2.id=tab3.id(+) and tab1.id=tab2.id
只是想要一种更快的方案