SQL批量更新数据

1) 第一种

update 表1
SET 表1.CnasDate=t1.日期
FROM (select 日期,Id from 表2) as t1
left join 表1 as t2
ON t1.Id=t2.ID

2)第二种(更简洁的写法 推荐)

update
表一
set
表一的字段= 表2的字段
from
表一,
表二
where
表一.Id = 表二.Id

Demo

update
a
set 
a.name = b.name
from
a,
b
where a.id = b.id

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2021-09-29
  • 2021-07-21
  • 2022-02-21
  • 2022-12-23
猜你喜欢
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2021-09-01
相关资源
相似解决方案