How to delete duplicates on a MySQL table?

后端 未结 25 2422
遇见更好的自我
遇见更好的自我 2020-11-22 01:35

I need to DELETE duplicated rows for specified sid on a MySQL table.

How can I do this with an SQL query?

         


        
25条回答
  •  长发绾君心
    2020-11-22 02:09

    This here will make the column column_name into a primary key, and in the meantime ignore all errors. So it will delete the rows with a duplicate value for column_name.

    ALTER IGNORE TABLE `table_name` ADD PRIMARY KEY (`column_name`);
    

提交回复
热议问题