SQL Server 多表联合更新方法

复制代码
update Table1 
set BidAgent=x.BidAgent
from Table1 t1,(select c.Id,a.BidAgent from Table1 c
left join Table2 b
on c.PurchaseItemId=b.PurchaseItemId
left join Table3 a
on a.Id=b.ParentId
where a.BidAgent is not null and c.BidAgent is null) x
where t1.Id=x.Id

先将需要的更新数据和待更新的表id查出来放在一个表x上,再关联这个表x更新就好

相关推荐
2501_9411481540 分钟前
多语言微服务架构与边缘计算技术实践:Python、Java、C++、Go深度解析
数据库
w***z501 小时前
MYSQL 创建索引
数据库·mysql
章鱼哥7302 小时前
[特殊字符] SpringBoot 自定义系统健康检测:数据库、Redis、表统计、更新时长、系统性能全链路监控
java·数据库·redis
5***E6852 小时前
MySQL:drop、delete与truncate区别
数据库·mysql
记得记得就1513 小时前
【MySQL数据库管理】
数据库·mysql·oracle
Austindatabases3 小时前
给PG鸡蛋里面挑骨头--杭州PostgreSQL生态大会
数据库·postgresql
秃了也弱了。3 小时前
MySQL空间函数详解,MySQL记录经纬度并进行计算
android·数据库·mysql
星环处相逢3 小时前
MySQL数据库管理从入门到精通:全流程实操指南
数据库·mysql
h***04774 小时前
SpringBoot集成Flink-CDC,实现对数据库数据的监听
数据库·spring boot·flink
源来猿往4 小时前
redis-架构解析
数据库·redis·缓存