MySQL Find and Replace

Quite often I find myself needing to replace certain content in my database, but some of my databases have hundreds, even thousands of rows. I don’t want to sift through all that and manually replace everything! And, I hope you don’t either. Well, I would assume that’s why you’re here.

Here’s a handy SQL code that will find and replace a string withing your database.

1
UPDATE [TABLE] SET [FIELD] = REPLACE([FIELD], '[string_to_find]', '[string_to_replace]');

It’s a very handy little script.

Enjoy!

August 12th, 2009 | Web Development

Leave a Reply

Name:
Email:
Website:
Message:
SUBMIT