MYSQL错误:You can't specify target table for update in FROM clause

这句话意思是:不能先select再更新(修改)同一个表。

可以再外嵌套多一层,这个问题只有mysql有,mssql和oracle都没有。

# 出错
delete from Person
where Id not in (
  select min(Id) as Id from Person group by Email);
# 正确
delete from Person
where Id not in (
  select Id from (
    select min(Id) as Id from Person group by Email) p);
上一篇:flask中需要的基本配置信息


下一篇:sonar6.7.6安装及汉化