DELETE A FROM A LEFT JOIN (SELECT NAME,MAX(TIME) AS MA FROM A GROUP BY NAME) B ON A.NAME=B.NAME AND A.TIME=B.MA WHERE B.NAME IS NULL
delete from mytable t where exists (select 1 from mytable where a=t.a and `time`>a.`time`);
delete a from table1 a left join (select name,max(time) as time from table1 group by name) b on a.name=b.name and a.time=b.time where b.name is null这里的a 不是字段的意思,只不过是个别名,把table1 换成你的表名就可以了。
on a.name=b.name and a.time=b.time
where b.name is null
字段名name,time
a,2009-12-30 20:12:43
a,2010-1-10 3:19:42
a,2010-1-15 13:39:12
执行删除后结束为
a,2010-1-15 13:39:12
ON A.NAME=B.NAME AND A.TIME=B.MA WHERE B.NAME IS NULL
(select 1 from mytable where a=t.a and `time`>a.`time`);
on a.name=b.name and a.time=b.time
where b.name is null这里的a 不是字段的意思,只不过是个别名,把table1 换成你的表名就可以了。