select * from dlog_user group by username
having count(username)>1
与下面一样:
select * from dlog_user group by username
having count(*)>1
删除重复数据:
delete from dlog_user d where userid>(select min(userid) from dlog_user where username=d.username);但mysql中执行会出错??
having count(username)>1
与下面一样:
select * from dlog_user group by username
having count(*)>1
删除重复数据:
delete from dlog_user d where userid>(select min(userid) from dlog_user where username=d.username);但mysql中执行会出错??
本文介绍了一种使用SQL查询来查找数据库表中重复记录的方法,并提供了一个具体的例子来展示如何通过GROUP BY结合HAVING子句来筛选出重复的用户名。此外,还探讨了删除重复数据的一种方法,虽然该方法在MySQL中可能会遇到执行错误。
763

被折叠的 条评论
为什么被折叠?



