MySQL Find and Replace with helper tool that generates SQL for you

How to find and replace text in MySql with an online tool that generates SQL for you.

test

So this is the SQL for replacing some text in MySQL database:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

So if you had a table named "documents" in your database where you wanted to go trough content and replace all absolute URL's with relative ones, you would have something like this:

update documents set content = replace(content, 'http://www.yourwebsite.com/','/');

And now that we went trough the boring stuff, here is something to make it a bit easier.

P.S. The image in header is made by my girlfriends and mine fingers (except for the MySql text which was added in Photoshop) on the iPhone with Brushes app

Comments

Thank you very much for this tool! It definitely saved me a lot of time!

Ariel 26. Aug 2010 at 12:50 PM

No problem! This is one of those things I did out of my own laziness :)

bananica 26. Aug 2010 at 12:55 PM Reply to: Ariel

Absolutely fantastic!! I was tearing my hair out until I found this tool, so easy!!!

D Murphy 25. Jan 2011 at 11:49 AM

Sometimes field name must be in quotes ``, if it is kind of special word used somewhere in SQL syntax (probably). For example fulltext doesn't work, gets replaced by FULLTEXT and error is displayed, but `fulltext` works fine. I found out this today.

darekk 2. Dec 2013 at 1:38 AM Reply to: D Murphy

Leave a comment

*
Leave your e-mail if you would like to get reply from me. Your e-mail will not be shown on my web page nor will I use it for anything other than replying to your question/comment.
**
Leave your website address if you want an extra link pointing to it ;)