我无法弄清楚如何使这个查询运行….我想更新表,以便依赖于uuid它抓住’last_updated’的最低点并更新’created_on’…我不断得到’不能指定目标表’虽然我不知道为什么= /这是一个递归问题?
UPDATE dlp.address AS t1
SET created_on = (SELECT MIN(last_updated)
FROM dlp.address AS t2
WHERE t1.addressuuid = t2.addressuuid);
最佳答案
UPDATE dlp.address AS t1
INNER JOIN
(
SELECT addressuuid, MIN(last_updated) minDate
FROM dlp.address
GROUP BY addressuuid
) AS t2
ON t1.addressuuid = t2.addressuuid
SET t1.created_on = t2.minDate