SQL语言-请教

来源:百度知道 编辑:UC知道 时间:2024/06/06 14:54:51
前提:有两个数据表A和B,其中A表里有以下字段:ID,a,b ;B表里有
以下字段:ID,a,b 。
问题:需要批量更新A表a,b两字段的内容为对应b表a,b的内容,条件为
A.ID=B.ID。

update A set A.a=B.a,A.b=B.b
from A ,B
where A.id=A.id

楼上的改个字:
update A set A.a=B.a,A.b=B.b
from A ,B
where A.id=B.id

或:
Update A Set a=(select a from B where Id=A.Id), b=(select b from B where Id=A.Id)

看一下参考书,挺容易的

关注