Delete MySQL Duplicates: Keep One Record
You can use the following steps to remove duplicate values and keep only one:
- First, use the SELECT DISTINCT query to find all unique values.
- Retrieve unique records from your_table.
- Create a temporary table and insert non-duplicate data into it.
- Create a temporary table with the same structure as your_table and insert all unique rows from your_table into the temporary table.
- Delete the original table.
- Delete the table named “your_table”.
- Rename the temporary table to the name of the original table.
- Change the table name from tmp_table to your_table.
Now, your table will only keep a single unique piece of data. Please make sure to backup your data before carrying out this operation to prevent any accidental loss of data.