当前位置: 首页> 教育> 高考 > 国际贸易新闻最新消息_太原seo团队_百度官方网站下载安装_网络舆情的网站

国际贸易新闻最新消息_太原seo团队_百度官方网站下载安装_网络舆情的网站

时间:2025/7/11 18:15:34来源:https://blog.csdn.net/qq_43144822/article/details/142754729 浏览次数:0次
国际贸易新闻最新消息_太原seo团队_百度官方网站下载安装_网络舆情的网站

1、单子段(nick_name)
查询所有有重复记录的所有记录
select * from user where nick_name in (select nick_name from user group by nick_name having count(nick_name)>1);
查询出有重复记录的各个记录组中的ID最大的记录
select * from user where id in (select max(id) from user group by nick_name having count(nick_name)>1);
查询出多余的记录,不查出id最小的记录
select * from user where id in (select max(id) from user group by nick_name having count(nick_name)>1);
删除多余的重复记录,只保留id 最小的记录
delete from user where nick_name in (select nick_name from (select nick_name from user group by nick_name having count(nick_name)>1) as tmp1) and id not in (select id from (select min(id) from user group by nick_name having count(nick_name)>1) as tmp2);

2、对字段
查出所有有重复记录的记录
select * from user where (nick_name,password) in (select nick_name,password from user group by nick_name,password where having count(nick_name)>1);
查出有重复记录的各个记录组中ID最大的记录
select * from user where id in (select max(id) from user group by nick_name,password where having count(nick_name)>1);
查处各个重复记录组中多余的鸡柳数据,不查出id最小的一条
select * from user where (nick_name,password) in (select nick_name,password from user group by nick_name,password having count(nick_name)>1) and id not in (select min(id) from user group by nick_name,password having count(nick_name)>1);
删除多有的重复记录,只保留id最小的记录】
delete from user where (nick_name,password) in (select nick_name,password from (select nick_name,password from user group by nick_name,password having count(nick_name)>1) as tmp1) and id not in (select id from (select min(id) id from user group by nick_name,password having count(nick_name)>1) as tmp2);

关键字:国际贸易新闻最新消息_太原seo团队_百度官方网站下载安装_网络舆情的网站

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: