SQL method to filter out duplicate data: Use the "select * from table name where condition" statement to filter out duplicate data; you can use one or more tables, use commas (,) to separate the tables, and use WHERE statement to set query conditions.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Open the database on your computer, and create a new user table with duplicate data as an example.
Query the duplicate data of the user table in the database.
select * from user where name in (select name from user group by name having count(name) > 1)
Delete duplicate name data
delete from user where name in (select name from user group by name having count(name) > 1)
Remove duplicate data, here the duplicate data of Zhang San is removed
select distinct name from user
Remove duplicate data of the same class
select distinct class from user
Remove duplicate data of two fields
select distinct name,class from user
Related free learning recommendations: mysql video tutorial
The above is the detailed content of How to filter out duplicate data in sql. For more information, please follow other related articles on the PHP Chinese website!