Oracle如何用关联查询结果更新一个表

wushangjimo 2013-03-27 08:27:16
oracle 11g,情况是这样的,A(id,b_id,str) B(id,str);现在通过要求是如果A.str=B.str,则把B.id写入A.b_id中。求高手指点一下~~~~
...全文
230 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hello_cyx 2013-03-28
  • 打赏
  • 举报
回复
update a set a.id = (select b.id from b where b.str = a.str)
ICE-word 2013-03-28
  • 打赏
  • 举报
回复
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)
  • 打赏
  • 举报
回复
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)

17,377

社区成员

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

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