首页 > 数据库技术 > 详细

sql去重复

时间:2018-05-29 13:49:56      阅读:202      评论:0      收藏:0      [点我收藏+]
  • 假设存在一个主键ID,Name为重复列,下面这句可以查出所有的没有重复的数据:  

  • select * from 表 as a where ID=(select min(ID) from 表 where Name=a.Name) 。

  • 根据上面这句就可以删除所有重复项的数据:                                                    

  • delete from 表 where ID not in(select ID from 表 as a where ID=(select min(ID) from 表 where Name=a.Name))。

   执行:select * from T_COM_SMSCLog as a where ID=(select min(ID) from T_COM_SMSCLog  where LoginName=a.LoginName and SendType=2 and IsSuccess!=1 and SMSId=505)

sql去重复

原文:https://www.cnblogs.com/yidengbone/p/9104509.html

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