Consider a situation, that needs to modify some string part of a column in a table with a large amount of rows.
For such situations, manually modifying the database (by taking the dump of the table and changing the queries in the dump with editor by find and replace the column content) , would be a hectic process:-(. For that there is a simple Query to update and replace the part of the column content. Following is the syntax with example:
UPDATE table_name SET column_name = REPLACE(column_name,”original_string”,”replace_string”)[/sql]
Here is what I did to change the path URLs in all the previous posts.
[sql]UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`,”mydummysite.com/wp”,”tinytip.blogspot.com/blog”)[/sql]
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment