How to delete records in the table which are repeated?

前端 未结 6 1774
长情又很酷
长情又很酷 2021-01-25 03:35

Hi Here i came across a situation in which by mistakenly Without dropping the table i have run the batch file of the table which consists of some insert statements in detail

6条回答
  •  温柔的废话
    2021-01-25 04:20

    In SQL-Server it would be easy using ROW_NUMBER, but alas MySQL doesn't have a function like that :-(

    Best way to solve it would be as follows:

    • Create a new table identical in structure to the first, but with no data.
    • Use the query: INSERT INTO name_of_new_table SELECT DISTINCT * FROM name_of_old_table
    • Drop the old table
    • Rename the new table to whatever the old table was called.

提交回复
热议问题