2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

Eliminate duplicate data from a table

I have a table which is not having primary key on any column.

While doing some operations duplicate data has been inserted into my table.

I want to delete the duplicated data.

Please help

userimage

To delete duplicated records firstly you need to find our some columns which we can treat like primary keys or on which columns of that table you will create primary key.Take that columns and use below query.


Delete from table_name where rowid not in (select max(rowid) from table_name group by primary_key_column1, primary_key_column2);

Make sure that after group by clause you should write the columns which can be primary key for that table.

Immediately create primary key on that columns.


Answer is