how to remove duplicates value in database table

Published on Author bloggerfiveLeave a comment

To remove duplicate value from the table is very simple. if it has primarykey that make more convenient.

The below query shows how to delete duplicate with maximum value.

   delete
        from db.task_table
        where taskId in (
        select * from (
                    select
                    max(taskId) as taskId
                    from db.task_table        
                    group by taskId
                    HAVING count(*) >1) A
                     )

Comments

comments

Leave a Reply

Your email address will not be published. Required fields are marked *