sql server 判断表A中的a,b列值等于表B中的a,b列的值时,更新B表中c列里面的值

2025-04-26 06:12:20
推荐回答(3个)
回答1:

1.update tableB set c=(select top 1 c from tableA where tableB.a=tableA.a and tableB.b=tableA.b)
2.update tableB set c= tableA.c
from tableB,tableA where tableB.a=tableA.a and tableB.b=tableA.b

回答2:

update B set c = A.c from A,B where A.a = B.a and A.b = B.b

回答3:

update A set A.c=B.c
from A
inner join B on A.a=B.a and A.b=B.b