数据库删除数据表重复数据,只留下ID较小的行

 删除表中重复数据,留下ID比较小的行

delete   from    表
where   [重复字段]     in   (select     [重复字段]     from  表     group     by     字段     having     count([字段])   >   1)
and   ID  not  in  (select   min(ID)   from     [表]     group   by   [字段]     having   count([字段])> 1)

 

posted @ 2015-04-07 11:14  水蓝色的梦  阅读(195)  评论(0编辑  收藏  举报