create table tmp SELECT * from lhb t where t.id not in (select max(id) from lhb group by code,date,reason); delete from lhb where id in(select id from tmp); drop table tmp;
mysql无法进行子查询删除,使用新建一个临时表,删除跟临时表里面不一样的数据,然后再删除临时表
zhidong123 2017-03-23 17:01 原文
create table tmp SELECT * from lhb t where t.id not in (select max(id) from lhb group by code,date,reason); delete from lhb where id in(select id from tmp); drop table tmp;
mysql无法进行子查询删除,使用新建一个临时表,删除跟临时表里面不一样的数据,然后再删除临时表