有三个表
Email
ID
10
11
12
SLA_DATE
ID | Email_ID
21 | 10
22 | 11
23 | 12
SLA
ID | Email_ID
33 | 10
34 | 11
35 | 12
我正在尝试将SLA Email_ID从Email.ID更新为SLA_DATE.ID。 因此,在更新SLA之后,该表应该看起来像
SLA
ID | Email_ID
33 | 21
34 | 22
35 | 23
以下是我到目前为止所尝试的内容..
UPDATE SLA SET
SLA.Email_ID = SLA_DATE.ID WHERE SLA_DATE.Email_ID = SLA_EMAIL_ID
答案 0 :(得分:3)
UPDATE s
SET s.Email_ID = d.ID
FROM SLA s
INNER JOIN
SLA_DATE d
ON d.Email_ID = s.Email_ID
答案 1 :(得分:0)
这应该有效
Update S SET S.EmailID = D.ID
From SLA A
Join SLA_DATE D On D.Email_ID = S.Email_ID