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

How to delete duplicate fields in data table using sql statement

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-08-08 09:30:06935browse

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

 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;

 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); 

 3. Delete temporary table

drop table tmp;

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

The above introduces the method of deleting duplicate fields in the data table using SQL statements, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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