SQL命令 - 带内连接的UPDATE

时间:2015-09-22 10:36:00

标签: sql

我有树桌:

表A:ID(PK),X,Y

表B:ID(非PK),CID

表C:ID(PK),X,Y

和(B.ID = C.ID) 和---条件---> A.X = C.X And A.Y = C.Y

我如何设置B.CID = C.ID?

1 个答案:

答案 0 :(得分:0)

UPDATE B
SET CID = C.ID
FROM dbo.TableA A
JOIN dbo.TableC C ON A.X = C.X AND A.Y = C.Y
JOIN dbo.TableB B ON B.ID = C.ID