5fcb66d1826d61790.jpg_fo742.jpg

You can’t specify target table for update in FROM clause

mysql不能在同一表中查询的数据作为同一表的更新数据
mssql和Oracle不会出现此问题
规避:
将select出的结果再通过中间表select一遍

delete from tbl where id in 
(
    select a.id from 
    (
        select max(id) id from tbl a where EXISTS
        (
            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1
        )
        group by tac
    ) a
)

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code