首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

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

2013-03-01 
(转)Mysql删除重复的记录(只保留一条)转自:http://www.php18.com/archives/Mysql_3012.htmlMysql删除重复

(转)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 就是不想重复的字段

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

热点排行