查找与删除重复的记录
[ 2011-05-20 17:04:27 | 作者: admin ]
//查找重复的记录
SELECT `loginname` , count( `loginname` ) AS num
FROM nth_member
GROUP BY loginname
ORDER BY num DESC
//删除重复的记录
DELETE nth_member AS a FROM nth_member AS a,
(
SELECT *
FROM nth_member
GROUP BY `loginname`
HAVING count( 1 ) >1
) AS b
WHERE a.loginname = b.loginname
AND a.id > b.id
评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=1679
SELECT `loginname` , count( `loginname` ) AS num
FROM nth_member
GROUP BY loginname
ORDER BY num DESC
//删除重复的记录
DELETE nth_member AS a FROM nth_member AS a,
(
SELECT *
FROM nth_member
GROUP BY `loginname`
HAVING count( 1 ) >1
) AS b
WHERE a.loginname = b.loginname
AND a.id > b.id

这篇日志没有评论。
此日志不可发表评论。