mysql去重

select count(*),oId  from afl_taobao_rate group by oId order by count(*) desc
afl_taobao_rate 裏面的oid重複,要求重複只留一條
1.建立臨時表
create   table   tmp   as   select   *   from   afl_taobao_rate   group   by   oId

2.給臨時表加uniqu限制
ALTER TABLE tmp ADD unique(`oId`);

3.備份原始表
alter   table   afl_taobao_rate   rename   afl_taobao_rate2

4.將臨時表 改爲目標表
alter   table   tmp   rename   afl_taobao_rate

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章