Mysql Search and Replace.

Posted on Friday the 31st of August, 2007 at 2:53 am in Asides, Dev, WordPress

I’ve been getting ready for WordPress 2.3, so in preparation I’ve started cleaning up my database. My first order of business was to clean up the tags database. Over time I’ve used several different methods of separating words: all spaces, hyphens and underscores have all been used which really makes the nice names ugly. Fixing this was easy, I just used the MYSQL replace command:

UPDATE `table` SET `field` = REPLACE(Field,'change_me','to_me');

Or specifically for the tags:

UPDATE `wp_tags` SET `tag` = REPLACE(tag,'_',' ');

Leave a reply

:) :D :( :o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: ;) :!: :?: :idea: :arrow: :| :mrgreen: