Mysql Remove Duplicate rows
这两天做项目一直在发愁,导入到mysql 里面的数据,有duplicate,应该还不少。
重新导入吧,数据量太大,需要很长时间。在网上搜索了半天。终于找到了.
原来有一个很简单的语句
CREATE TABLE new_table as
SELECT * FROM old_table WHERE 1 GROUP BY [column to remove duplicates by];
Just replace old_table as your table name;
Replace "[column to remove duplicates by]" as all your column names, for example id,name;
Thus,the new table named new_table will contain all the records from old table without duplicate.
重新导入吧,数据量太大,需要很长时间。在网上搜索了半天。终于找到了.
原来有一个很简单的语句
CREATE TABLE new_table as
SELECT * FROM old_table WHERE 1 GROUP BY [column to remove duplicates by];
Just replace old_table as your table name;
Replace "[column to remove duplicates by]" as all your column names, for example id,name;
Thus,the new table named new_table will contain all the records from old table without duplicate.
评论