日期:2014-05-17  浏览次数:20793 次

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)