I need to delete the exact duplicate records from a table with 30 columns.
My data would look something as attached.Advance Thanks!!
Asked
Active
Viewed 322 times
-1
-
5The image is too large but too small – Lithu T.V Jun 13 '13 at 10:21
-
which exactly rows should be considered as duplicated? what is the condition? e.g. there should be repeating rows with the same colum1 and colum2 values – heximal Jun 13 '13 at 10:22
-
@Lithu T.V, took me a while to get what you mean, lol – lkdg Jun 13 '13 at 10:27
-
Did you search first? Been answered many times. – David Aldridge Jun 13 '13 at 14:59
2 Answers
1
Your question I understood like this...
1) if you want to delete only one record from duplicate rows.In this case you need a column date with (current timestamp) in table
delete from tableName t1 where
t1.id in (SELECT t2.id
FROM tableName t2
where t1.id = t2.id and t1.date(timestamp) < t2.date(timestamp))
2) if you want delete complete duplicate rows
delete from tableName t1 where
t1.id in (SELECT t2.id
FROM tableName t2
group by t2.id
having count(*) >1)

Narayan Yerrabachu
- 1,714
- 1
- 19
- 31