oracle怎实现全连接?急!!

xieguogui 2003-08-26 09:43:56
a.f = b.f(+) 或 a.f(+) = b.f 都可以,但我想左右都连接上,可不可以
a.f(+)=b.f(+),好像不行,怎么办?请教!
...全文
869 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
enhydraboy 2003-08-28
  • 打赏
  • 举报
回复
"ORA-00918: column ambiguously defined为什么?"
仔细检查你里面的连接部分的select语句,肯定没有在同名的列前,加上表名。

"除了用union还有其他办法吗?弱oracle!!",方法有,只不过你没有耐性去解决你的语句bug。
xieguogui 2003-08-28
  • 打赏
  • 举报
回复
真的没有人会吗?
LGQDUCKY 2003-08-26
  • 打赏
  • 举报
回复
用enhydraboy(乱舞的浮尘):的方法无觉得好,
select A.*,B.* from a,B where a.f = b.f(+)
union ALL
select A.*,B.* from a,B where a.f(+) = b.f;

LGQDUCKY 2003-08-26
  • 打赏
  • 举报
回复
select A.*,B,* from a,B where a.f = b.f(+)
union ALL
select A.*,B,* from a,B where a.f(+) = b.f
enhydraboy 2003-08-26
  • 打赏
  • 举报
回复
左连接 union 右连接,不就可以了。
xieguogui 2003-08-26
  • 打赏
  • 举报
回复
我用的是oracle 8i怎么办?难道就没有办法了吗?oracle就这么弱吗?
yaotiebing 2003-08-26
  • 打赏
  • 举报
回复



SQL> SELECT ename||job AS "Employees"
2 FROM emp;
enhydraboy 2003-08-26
  • 打赏
  • 举报
回复
也许oracle 9i支持这种写法吧。
yaotiebing 2003-08-26
  • 打赏
  • 举报
回复
使用 || 连接符
jiezhi 2003-08-26
  • 打赏
  • 举报
回复
in oracle9i,you can use full out join
jiezhi 2003-08-26
  • 打赏
  • 举报
回复
a full out join b on ... --->
Return all rows from the a table and all rows from the b table.
Rows that do not satisfy the ON conditionare extended with nulls.
xieguogui 2003-08-26
  • 打赏
  • 举报
回复
full outer join 好像是SQL Server才可以用的吧?
jiezhi 2003-08-26
  • 打赏
  • 举报
回复

SELECT c.customer_id, c.o.order_id, c.account_mgr_id, o.sales_rep_id
FROM customers c FULL OUTER JOIN orders o
ON c.customer_id = o.customer_id
ORDER BY c.customer_id;
enhydraboy 2003-08-26
  • 打赏
  • 举报
回复
select ...
from a,f
where a.f = b.f(+)
union
select ...
from a,f
where a.f(+) = b.f
xieguogui 2003-08-26
  • 打赏
  • 举报
回复
除了用union还有其他办法吗?弱oracle!!
xieguogui 2003-08-26
  • 打赏
  • 举报
回复
select * from
(

(
select kh.sm,kh.cnt,xh.cnt
from
(select sm,count(*) cnt from tbm_yd,tyt_yhda where dm=yd and to_char(khsj,'yyyymmdd') = '20030825' group by sm) kh,
(select sm,count(*) cnt from tbm_yd,tyt_xhyd where dm=yd and to_char(xhsj,'yyyymmdd') = '20030825' group by sm) xh
where kh.sm=xh.sm(+)
)
union all
(
select kh.sm,kh.cnt,xh.cnt
from
(select sm,count(*) cnt from tbm_yd,tyt_yhda where dm=yd and to_char(khsj,'yyyymmdd') = '20030825' group by sm) kh,
(select sm,count(*) cnt from tbm_yd,tyt_xhyd where dm=yd and to_char(xhsj,'yyyymmdd') = '20030825' group by sm) xh
where kh.sm(+)=xh.sm
)

)

ORA-00918: column ambiguously defined
为什么?

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧