Home > Database > Mysql Tutorial > How to remove duplicate fields in mysql table

How to remove duplicate fields in mysql table

anonymity
Release: 2020-09-16 11:03:42
Original
4490 people have browsed it

Mysql method to remove duplicate fields in the table: [delete deletion condition in (select unique identification column from table (extract duplicates) rename table))]. The deduplication operation in mysql generally requires multi-level statement nesting.

How to remove duplicate fields in mysql table

MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently a product of Oracle. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System) application software.

(Recommended tutorial: mysql video tutorial)

Problem found?

The same data appears multiple times in the same table. My requirement is to delete redundant data but keep one of them.
Define the table name table_a, determine the only two fields c_1, c_2, and the irrelevant field data
The original data in the table is as follows

How to remove duplicate fields in mysql table

Delete statement:

DELETE FROM table_a 
WHERE id IN 
(SELECT id FROM 
(
SELECT id FROM table_a GROUP BY c_1,c_2 HAVING count(*) > 1
)e
);
Copy after login

The above is the detailed content of How to remove duplicate fields in mysql table. For more information, please follow other related articles on the PHP Chinese website!

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