Add to Favorites

String Replace in mysql

Say that you have a database full of blog posts and by chance you have misspelled a word many times throughout your blogging. You may think that you will have to go back and edit each of your blog posts but if you have access to the database you can run a replace on all of them and fix your mistake.

String replacements in mysql are pretty simple, the standard syntax being
REPLACE([string or column],'thing to replace','thing to substitute')

You could run a replace update query on your blog post database,
update blog_post set post_body = REPLACE(post_body,'axcident','accident');

This will save you lots of time and labor in editing each post.


Be the first to leave a comment on this post.

Leave a comment

To leave a comment, please log in / sign up