在一个更新语句中 in 一个当前表的子查询 会出现错误 You can’t specify target table for update in FROM clause

解决方法: 在子查询外包裹一个 查询语句 SELECT a.id FROM (子查询)a

UPDATE users_address
SET is_default = 1
WHERE
    id IN (
        SELECT
            a.id
        FROM
            (
                SELECT
                    max(id) AS id
                FROM
                    `users_address`
                GROUP BY
                    uid
            ) a
    )

参考地址: http://www.jb51.net/article/60926.htm