我有 2 个表的日期字段与需要不匹配。
首先,我有一个查询来返回所有需要更新日期字段的记录列表。
SELECT distinct ID_NUMBER
FROM a
INNER JOIN b
ON a.ID_NUMBER = b.ID_NUMBER
INNER JOIN c
ON c.ID_NUMBER = b.ID_NUMBER
INNER JOIN d
ON c.ID_NUMBER = d.ID_NUMBER
WHERE d.DATE <> b.DATE
返回 20K 加上 ID_NUMBER 的
我想更新表 B,其中 ID_Number = 该查询中的 ID_numbers 列表。
试:
UPDATE b
SET d.DATE = b.DATE
Where (select distinct ID_NUMBER
from a
INNER JOIN b
ON a.ID_NUMBER = b.ID_NUMBER
INNER JOIN c
ON c.ID_NUMBER = b.ID_NUMBER
INNER JOIN d
ON c.ID_NUMBER = d.ID_NUMBER
Where d.DATE <> b.DATE
)
应该是直截了当的。似乎无法获得语法。帮助表示赞赏。