mysql将去重以后的记录导入新表

来源:互联网 发布:mac 图标大小 编辑:程序博客网 时间:2024/04/29 21:02

一:新建空表,字段包含id和将导入的字段名field1,field2,……

二:在Mysql控制台中,执行命令:

insert into target_table(id,field1,field2,……) select @row :=@row+1 as id,t1.* from(select distinct field1,field2,…… from source_table) t1,(select @row :=0) as t2

target_table为新建表,source_table为旧有表。
0 0