Posted By

thepiglovesyou on 02/15/11


Tagged


Versions (?)

MySQL: remove duplicated records from table


 / Published in: PHP
 

  1. $mdb2->exec('CREATE TABLE temp_table as SELECT * FROM hatebu_hotentries GROUP BY link;');
  2. $mdb2->exec('DROP TABLE hatebu_hotentries;');
  3. $mdb2->exec('ALTER TABLE temp_table RENAME TO hatebu_hotentries;');
  4. $mdb2->exec('ALTER TABLE hatebu_hotentries ADD PRIMARY KEY(id);');
  5. $mdb2->exec('ALTER TABLE hatebu_hotentries ADD INDEX ( id );');
  6. $mdb2->exec('ALTER TABLE hatebu_hotentries CHANGE id id INT NOT NULL AUTO_INCREMENT;');

Report this snippet  

You need to login to post a comment.