求sql语句 A表有 列1,列2 B表有 列1,列2 现在想 如果 A表列1=B表列1,用B表列2的值替换A表列2的值

a,b两个表在同一个数据库里
2025年03月01日 04:52
有2个网友回答
网友(1):

uddate tableA set 列2=tableB.列2 from tableA tableB where tableA .列1=tableB .列1

网友(2):

update t1
set 列2=t2.列2
from 表A T1,
表B t2
where t1.列1=t2.列1