注意點:
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
解決了我的需求,記錄一下。