Home >Database >Mysql Tutorial >删除重复记录的sql语句

删除重复记录的sql语句

WBOY
WBOYOriginal
2016-06-07 17:47:401341browse

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

删除重复记录的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
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn