尝试了百度搜到的前几个答案,没一个可用。注意:c1,c2是用来判断重复的条件。
DELETE FROM table
WHERE id NOT IN(
SELECT id FROM
(
SELECT MIN(id)AS id
FROM table
GROUP BY c1,c2 HAVING
COUNT(*) > 1
)AS a )
AND id NOT IN(
(SELECT ids FROM
(
SELECT MIN(id)AS ids
FROM table
GROUP BY c1,c2 HAVING
COUNT(*) =1
)AS a1
)
)