Find and delete duplicate records from a table - MySQL
1. MySQL - Find duplicate records
SELECT column_name, COUNT(column_name) as 'Number of occurrences' FROM table_name
GROUP BY column_name HAVING COUNT(column_name) > 1;
2. MySQL - Delete duplicate records from a table
delete t1 from table t1, table t2 where t1.column_name_duplicate=t2.column_name_duplicate AND t1.id < t2.id;
Note : table - > name of table
column_name_duplicate -> column name which has duplicate values
id - > id column of table
Labels: delete duplicate records from a table, find duplicate records in a table, MYSQL
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home