delete from YOUR_TABLE where id not in (select id from (select max(id) as id from YOUR_TABLE group by UNIQUE_FIELD) as b);
[......]
delete from YOUR_TABLE where id not in (select id from (select max(id) as id from YOUR_TABLE group by UNIQUE_FIELD) as b);
[......]