0
UPDATE Customer C
SET name = B.name, 
age = B.age
FROM (SELECT A.*, B.* FROM CUSTOMER_TEMP WHERE A.ID = B.ID) AS B

我得到了一个如上所述的 sql,在我运行查询之后,它将我的所有行更新为相同的结果。

我想知道我需要一个之后的地方

UPDATE Customer C
SET name = B.name, 
age = B.age
FROM (SELECT A.*, B.* FROM CUSTOMER_TEMP WHERE A.ID = B.ID) AS D
WHERE C.ID = D.ID

但是我得到这个 id 对于最后一个查询是不明确的。

4

1 回答 1

0

尝试这个

update Customer set
    name = B.name, 
    age = B.age
from Customer as C
    inner join CUSTOMER_TEMP as B on B.ID = C.ID

SQL 提琴示例

于 2013-07-11T05:35:53.953 回答