In this post i will explain an extremely basic MySql Problem of Replacing a Text in mysql Table.Suppose You have a table name posts with title and description. There are some normal content or links you have included in your all posts like old site connection but now you want to update old links with new ones.But you don’t wanna do this manually one by one because you know very well that it will take months.So Now Lets be smart and use mysql query to find and replace all the links at onces.It will take less then a second.
find and replace sql query, mysql find and replace in column, mysql find and replace part of string, mysql find and replace regex, mysql search and replace wordpress, phpmyadmin find and replace url, replace query in mysql, sql find and replace string
|1||TITLE-1||My first description visit for more info www.growwebsite.com/subscribe||1|
|2||TITLE-2||My second description visit for more info www.growwebsite.com/subscribe||1|
|3||TITLE-3||My third description visit for more info www.growwebsite.com/subscribe||0|
In the above table there is a link (www.growwebsite.com/subscribe) in description column which i have to replace with www.growwebsite.com, For same MySql query will be..
SET DESCRIPTION = REPLACE(DESCRIPTION, 'www.growwebsite.com/subscribe', 'www.growwebsite.com');
You can also apply conditional query to replace text form only active posts by WHERE clause.
SET DESCRIPTION = REPLACE(DESCRIPTION, 'www.growwebsite.com/subscribe', 'www.growwebsite.com')