Possible Duplicate:
Remove duplicate rows in MySQL
How would I delete all duplicate data from a MySQL Table?
For example, with the following data:
SELECT * FROM names;
+----+--------+
| id | name |
+----+--------+
| 1 | google |
| 2 | yahoo |
| 3 | msn |
| 4 | google |
| 5 | google |
| 6 | yahoo |
+----+--------+
I would use SELECT DISTINCT name FROM names;
if it were a SELECT
query.
How would I do this with DELETE
to only remove duplicates and keep just one record of each?
转载于:https://stackoverflow.com/questions/4685173/delete-all-duplicate-rows-except-for-one-in-mysql