CREATE TABLE `abc` (
`id` int(11) DEFAULT NULL,
`veh_code` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DELETE FROM abc WHERE
veh_code IN (SELECT veh_code FROM
(select a.veh_code from ( SELECT id,veh_code FROM abc GROUP BY veh_code
HAVING COUNT(veh_code) > 1) a)
t1)
AND id NOT IN (SELECT
t2.maxid
FROM
(SELECT
max(id) maxid
FROM
abc
GROUP BY veh_code HAVING COUNT(veh_code) > 1) t2)