MySQL search and replace

It’s something that can have you pulling your hair out in frustration but the solution is so simple.

Finding (and replacing) text in your MySQL database tables has almost become a past time of mine recently, converting a foreign database into reading something a bit closer to the English language.

If you use a frontend to your MySQL database (like phpMyAdmin or SQLyog, Navicat, etc) then go to create a new query and enter the following (replacing the table and field names as required of course!):

UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring");

It’s Brian Zimmer I have to thank for that, so please view the example on his website for including more search options. Also worth a mention is MybesInformatik who’s site I stumbled on when I couldn’t remember the URL for Brian’s site!

Leave a Reply