要刪除重復行,可以使用以下步驟:
SELECT name, age, COUNT(*) FROM table1 GROUP BY name, age HAVING COUNT(*) > 1;
CREATE TABLE temp_table AS SELECT name, age FROM table1 GROUP BY name, age HAVING COUNT(*) > 1;
DELETE table1 FROM table1 INNER JOIN temp_table ON table1.name = temp_table.name AND table1.age = temp_table.age;
DROP TABLE temp_table;
通過執行以上步驟,你可以刪除MySQL表中的重復行。請注意,在執行刪除操作之前,最好先備份數據以防止意外刪除。