How do I delete all the duplicate records in a MySQL table without temp tables

前端 未结 9 1314
北恋
北恋 2020-11-27 03:46

I\'ve seen a number of variations on this but nothing quite matches what I\'m trying to accomplish.

I have a table, TableA, which contain the answers gi

9条回答
  •  醉梦人生
    2020-11-27 04:13

    Thanks to jveirasv for the answer above.

    If you need to remove duplicates of a specific sets of column, you can use this (if you have a timestamp in the table that vary for example)

    CREATE TABLE TableA_Verify AS SELECT * FROM TableA WHERE 1 GROUP BY [COLUMN TO remove duplicates BY];
    
    DELETE FROM TableA;
    
    INSERT INTO TableA SELECT * FROM TAbleA_Verify;
    
    DROP TABLE TableA_Verify;
    

提交回复
热议问题