Skip to content

MySQL删除重复记录只保留一条

🗓️ 更新于:19:38
标签:

delete from 表名 where 字段ID in (select * from (select max(字段ID) from 表名 group by 重复的字段 having count(重复的字段) > 1) as b);

来自 <http://www.open-open.com/lib/view/open1404568229186.html>

查询是否有相同值
SELECT `object_id` FROM `e_term_relationships` GROUP BY `object_id` HAVING COUNT( `object_id` ) >1
LIMIT 0 , 30