How To Delete Duplicate Rows From The Database Table?

Member

by melvina , in category: Technology , 3 years ago

How To Delete Duplicate Rows From The Database Table?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by sidney , 3 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