读书人

Oracle怎么用关联查询结果更新一个表

发布时间: 2013-04-07 12:50:11 作者: rapoo

Oracle如何用关联查询结果更新一个表
oracle 11g,情况是这样的,A(id,b_id,str) B(id,str);现在通过要求是如果A.str=B.str,则把B.id写入A.b_id中。求高手指点一下~~~~ oracle 多表更新?关联
[解决办法]
update a set a.id = (select b.id from b where b.str = a.str) where exists(select * from b where a.str = b.str)
[解决办法]
update A set A.id = (select b.id from b where b.str = A.str) where exists(select 1 from b where A.str = b.str)

读书人网 >oracle

热点推荐