mysql 去除重复项

表名:stu_info
字段有:id,name
创建一个临时表 tmp ,把表中的id作为字段并且以去重复的那项进行分组,把具有重复项的复制到一张表中


create table tmp as select min(id) as col1 from stu_info group by(name) ;
delete from stu_info  where id not in (select col1 from tmp);
drop table tmp;

猜你喜欢

转载自leo-cao.iteye.com/blog/1872910