读书人

单行子查询返回多于一个行,解决方法!

发布时间: 2014-01-28 21:25:53 作者: rapoo

表A,表B,
我要把表B的time数据覆盖A的time数据。。。
其中表B的id = 表A 的 id

update 表A a set a.time = ( select b.time from 表B b where a.id=b.id) where exists(select 1 from 表B b where a.id=b.id)

运行出错:单行子查询返回多于一个行

请大家告诉我下怎么改?
------解决方法--------------------------------------------------------
update 表A a
set
a.time=(select max(b.time) from 表B b where a.id=b.id)
where
exists(select 1 from 表B b where a.id=b.id)

        

读书人网 >oracle

热点推荐