(转)Mysql删除重复的记录(只保留一条)

转自: http://www.php18.com/archives/Mysql_3012.html

Mysql删除重复的记录(只保留一条)
原理很简单:
把不重复的记录复制到一个新table,  之后删除旧table, 再把新table改回旧table的名不就行了?

create table new_table_name  select *, count(distinct title_name) from old_table_name  group by title_name


new_table_name就是新表名

old_table_name 为原表名

title_name 就是不想重复的字段

注意:这个方法创建的新表后面会多一个字段,删除即可

猜你喜欢

转载自shineonly.iteye.com/blog/1816665