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

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

WBOY
Release: 2016-06-13 09:15:49
Original
1100 people have browsed it

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

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

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

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

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

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

  3.删除临时表

drop table tmp;
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template