[code]DELETE FROM mtk
WHERE
`code` IN (SELECT
*
FROM
(SELECT
`code`
FROM
mtk
GROUP BY `code`
HAVING COUNT(`code`) > 1) t1)
AND id NOT IN (SELECT
*
FROM
(SELECT
MIN(id)
FROM
mtk
GROUP BY `code`
HAVING COUNT(`code`) > 1) t2)[/code]