在mysql中使用:
DELETE FROM scores WHERE id not in ( SELECT min(id) GROUP BY name,score,subject);
报错:
You can't specify target table 'scores' for update in FROM clause这是mysql才有的错误。
替代:
create table tmp as select min(id) as col from scores group by name,score,subject; delete from scores where id not in (select col from tmp); DROP TABLE tmp;参考:https://zhidao.baidu.com/question/68619324.html