How To Delete Duplicate Rows From The Database Table?

Member

by melvina , in category: Technology , 4 years ago

How To Delete Duplicate Rows From The Database Table?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by sidney , 4 years ago

You can delete row using INNER JOIN clouse. see following example:

1
2
3
4
5
DELETE t1 
FROM table_name t1 
INNER JOIN table_name t2 
WHERE 
t1.id < t2.id AND t1.column_name = t2.column_name

Suppose,

table_name = user

column_name = email


then the query is:


1
2
3
4
5
DELETE t1 
FROM user t1 
INNER JOIN user t2 
WHERE 
t1.id < t2.id AND t1.email= t2.email


Related Threads:

What Are the Best Practices for Writing Secure Oracle Sql Queries?
What Are the Best Practices for Managing Oracle Sql Databases?
How to Improve Mysql Performance for Large Databases?
What Are the Commonly Used Oracle Query Tools for Beginners?
How to remove duplicate values from a PHP Array?
How to delete a record in Codeigniter?