你的位置:首页 > 数据库

[数据库]Mysql删除重复数据


//查出所有的content唯一的最小id

create table tmp as select min(id) as col1 from test group by content;

//删除重复数据
delete from test where id not in (select col1 from tmp);

//删除临时表
drop table tmp;

 

参考:http://blog.csdn.net/anya/article/details/6407280

http://zhidao.baidu.com/link?url=UkkbXfHKefCh_kGmoBBGDUO2xIa-gq1ZW-P4rMyP-0RadKMosDSK1SWuyqtGhtdFthc8gY4KwVNaFnvQu_TGEq