cleaning up db of redundant data

前端 未结 5 1661
时光说笑
时光说笑 2020-12-07 04:54
locid   country city
39409   US  Aaronsburg
128426  US  Aaronsburg
340356  US  Aaronsburg
429373  US  Aaronsburg
422717  US  Abbeville
431344  US  Abbeville
433062           


        
5条回答
  •  情书的邮戳
    2020-12-07 05:20

    Create a new table with new auto_increment field and just select them with GROUP BY into the new table

    Not tested but should look like this:

    INSERT INTO new_table(country, city) 
    SELECT country, city FROM old_table 
    GROUP BY country,city
    

    EDIT: You could drop the old_table and rename the new_table afterwards.

提交回复
热议问题