MySQL : How to do find and replace and remove duplicate entries

You, MySQLUtility
Back

Sometimes these small utility codes are really important when you stuck with a large amount of data. These are really straight forward queries.

How to do find a replace:

UPDATE TABLENAME set FIELD = replace(FIELD, 'FIND', 'REPLACE') where instr(FIELD, 'FIND') > 0;

Delete duplicate entries from a table : Adding a unique index do the job.

ALTER IGNORE TABLE TABLENAME ADD UNIQUE INDEX idx\_name (FIELD);
© Heshan Wanigasooriya.RSS

🍪 This site does not track you.