删除重复项,只保留id最小的一项

DELETE FROM spider_927
WHERE 1=1
AND title in (SELECT * FROM ( (SELECT title titles FROM spider_927 GROUP BY title HAVING COUNT(title)>1) ) a)
AND id not in (SELECT * FROM ( (SELECT MIN(id) ids FROM spider_927 GROUP BY title HAVING COUNT(title)>1) ) b)

posted @ 2019-09-13 01:29  修瑾  阅读(318)  评论(0编辑  收藏  举报