【www.gdgbn.com--php与数据库】

删除重复记录的sql语句
我们提供了两款删除重复记录的sql语句,一种是用id not in来实例,也算是联合查询的方法吧,第二种是临时表来删除重复记录。

1),delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)

 

2),select distinct * into temp from tablename
  delete from tablename
  insert into tablename select * from temp

本文来源:http://www.gdgbn.com/jiaocheng/26070/