问题:
在MySQL数据库删除重复数据的时候遇到了一个问题。如下sql:
delete from s where autoid not in(
select autoid from s group by id, name, no
);
报错:
大致意思是,在同一语句中,不能先select出同一表中的某些值,再update这个表。
解决方法:
需要对上述sql进行更改,查询的时候增加一层中间表,就可以避免该错误,如下:
delete from s where autoid not in(
select a.autoid from(
select autoid from s group by id, name, no
) as a
);