Possible Duplicate:
Remove duplicate rows in MySQL
I'd like to create an unique index on single attribute in a huge table, but there are duplicite values, so I need to remove the duplicity. Only duplicite records can be deleted. What is the best solution in phpmyadmin or mysql query to do this?
The only solution I figured out is to make select into another table, but I'd prefer to delete data from original table.
The table looks like this (I'd like to put unique index on id
)
|id|...
+--+---
| 1|x
| 2|a <-- duplicity
| 2|b <-- duplicity
| 3|c
| 4|d
This would be the best result
|id|...
+--+---
| 1|x
| 2|a
| 3|c
| 4|d
This is also acceptable result
|id|...
+--+---
| 1|x
| 3|c
| 4|d