sql删除重复记录 You can't specify target table '表名' for update in FROM clause
用下面的语句就报语法出错:
delete from 表名 where 字段名 not in (select min(c.字段名) as 字段名 from 表名 c group by (c.字段名));
报错如下:You can't specify target table '表名' for update in FROM clause
找到替代方案,改用下面的,OK:
delete from 表名 where 字段名 not in (select min(c.字段名) as 字段名 from (select * from 表名) c group by (c.字段名));
或者下面的也OK:
delete from 表名 where 字段名 not in (select * from (select min(字段名) as 字段名 from 表名 group by (字段名)) v);