Skip to content

Instantly share code, notes, and snippets.

@andreymeretsky
Created April 6, 2016 11:06
Show Gist options
  • Save andreymeretsky/390e19e041eb24818b47577bc3279623 to your computer and use it in GitHub Desktop.
Save andreymeretsky/390e19e041eb24818b47577bc3279623 to your computer and use it in GitHub Desktop.
Removing duplicate rows in table
CREATE TABLE tbl_fields_unique LIKE tbl_fields;
ALTER TABLE tbl_fields_unique
ADD UNIQUE KEY unq (fieldno,fieldserial,id,fielddate,fieldsid);
INSERT IGNORE INTO tbl_fields_unique
SELECT * FROM tbl_fields;
ALTER TABLE tbl_fields RENAME tbl_fields_old;
ALTER TABLE tbl_fields_unique RENAME tbl_fields;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment