MySQL: remove duplicated records from table

/ Published in: PHP
Save to your folder(s)

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.