Home >php教程 >php手册 >sql语句删除数据表重复字段的方法,sql语句

sql语句删除数据表重复字段的方法,sql语句

WBOY
WBOYOriginal
2016-06-13 09:15:491093browse

sql语句删除数据表重复字段的方法,sql语句

 大家都可能遇到字段重复的情况,网上很多人在找方法,也给出了一些方法,但是有的方法是误导大家,铁牛写出以下方法,方便大家使用

  1.通过group by把重复的字段筛选出来,并建立临时表tmp

create table tmp as select max(id) as col1 from www group by dfdfd;

  2.从去重表对象里通过not in的条件来筛选出不在临时表的列col1,执行not in的删除操作

delete from www where id not in (select col1 from tmp); 

  3.删除临时表

drop table tmp;

  欢迎加入PHP技术和职场交流群:383730534

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