56,677
社区成员
发帖
与我相关
我的任务
分享
delete from bbs_threads
where subject in (select subject from bbs_threads group by subject having count(subject)>1)
and tid not in (select min(tid) from bbs_threads group by subject having count(subject)>1)
delete b1 from bbs_threads b1 ,bbs_threads b2 where b1.subject=b2.subject and b1.tid>b2.tid;
DELETE A
FROM bbs_threads AS A
JOIN (
SELECT MIN(id) AS id,subject
FROM bbs_threads
GROUP BY subject
) AS B
ON A.subject=B.subject AND A.id>B.id;
--看看支不支持这种写法
DELETE A
FROM bbs_threads AS A
WHERE NOT EXISTS(SELECT * FROM bbs_threads
WHERE A.subject=subject
AND id<A.id);