如何在不更改/添加任何额外列的情况下从MySQL表中删除所有重复数据?

SELECT * FROM webs;

+--------+
|  web   |
+--------+
| google |
| google |
| msn    |
| yahoo  |
| msn    |
| yahoo  |
+--------+


结果应为:

+--------+
|  web   |
+--------+
| google |
| yahoo  |
| msn    |
+--------+

最佳答案

您可以通过一个临时表来实现:

CREATE TABLE temp SELECT DISTINCT * FROM webs;
DROP TABLE webs;
ALTER TABLE temp RENAME TO webs;

关于mysql - 删除重复记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55703588/

10-10 10:50