设为首页 加入收藏

TOP

mysql删除重复记录的sql语句与查询重复记录
2011-06-12 21:37:08 来源: 作者: 【 】 浏览:65次 评论:0


方法1
delete yourtable
where [id] not in (
select max([id]) from yourtable
group by (name + value))
方法2
delete a
from 表 a left join(
select (id) from 表 group by name,value
)b on a.id=b.id
where b.id is null
查询及删除重复记录的sql语句
查询及删除重复记录的sql语句
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleid)来判断
select * from people
where peopleid in (select peopleid from people group by peopleid having count(peopleid) > 1)
2、删除表中多余的重复记录,重复记录是根据单个字段(peopleid)来判断,只留有rowid最小的记录
delete from people
where peopleid in (select peopleid from people group by peopleid having count(peopleid) > 1)
and rowid not in (select min(rowid) from people group by peopleid having count(peopleid )>1)
3、查找表中多余的重复记录(多个字段)
select * from vitae a
where (a.peopleid,a.seq) in (select peopleid,seq from vitae group by peopleid,seq having count(*) > 1) 

您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇mysql服务器集群配置方法 下一篇mysql Can''t connect to..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位