Home > Backend Development > PHP Tutorial > How to delete duplicate fields in a data table using sql statement, sql statement_PHP tutorial

How to delete duplicate fields in a data table using sql statement, sql statement_PHP tutorial

WBOY
Release: 2016-07-13 10:08:07
Original
1175 people have browsed it

How to delete duplicate fields in a data table using sql statement, sql statement

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

1. Filter out duplicate fields through group by and create a temporary table tmp

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

2. Use the not in condition to filter out the column col1 that is not in the temporary table from the deduplication table object, and perform the not in deletion operation

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

 3. Delete temporary table

drop table tmp;
Copy after login

Welcome to join the PHP technology and workplace exchange group: 383730534

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/952777.htmlTechArticleHow to delete duplicate fields in a data table using sql statements. Everyone may encounter duplicate fields in sql statements. There are many on the Internet People are looking for ways, and some methods have been given, but some methods are wrong...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template