Mysql Search and Replace.

April 31, 2007 by aaron

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,'_',' ');

Categorized as:
comments powered by Disqus