首页 > 数据库技术 > 详细

Mysql去重三种语句

时间:2021-07-30 23:09:40      阅读:30      评论:0      收藏:0      [点我收藏+]

1.存在完全相同的纪录

select distinct * from table(表名) where (条件)

2.存在部分字段相同的纪录(有主键id即唯一键)

select * from table where id in (select max(id) from table group by [去除重复的字段名列表,....])

3.没有唯一键ID

   select identity(int,1,1) as id,* into newtable(临时表) from table

   select * from newtable where id in (select max(id) from newtable group by [去除重复的字段名列表,....])

   drop table newtable

Mysql去重三种语句

原文:https://www.cnblogs.com/wy0726/p/15080879.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!