注意点:
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
)
时间: 2024-11-08 03:21:52