Oracle多表關聯如何更新多個字段


注意點:
1、被update主表一定要加上過濾條件。
2、查詢出來更新結果集,同時也要作為被更新主表的條件,作為同步大家都是更新這部分數據。
update student stu
  set (stu.name,stu.sex) =
  (select bak.name,bak.sex
  from student_bak bak
  where bak.id = stu.id
  and stu.age = 20
  )
  where exists (select 1
  from student_bak bak
  where bak.id = stu.id
  and stu.age = 20
  )

 

轉自:https://www.cnblogs.com/chenweichu/p/7560489.html

解決了我的需求,記錄一下。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM