4

我不知道如何让这个查询运行....我想更新表,以便依赖于 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);
4

2 回答 2

2
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
于 2012-12-12T03:05:56.943 回答
0

您可以使用 :

UPDATE dlp.address AS t1

  , (SELECT addressuuid, MIN(last_updated) AS minDate 
       FROM dlp.address GROUP BY addressuuid) AS t2

SET t1.created_on = t2.minDate 

WHERE t1.addressuuid = t2.addressuuid
于 2012-12-12T03:23:39.083 回答