Here’s a couple things I always forget. I’m adding them here so I’ll have them for future reference.
How to “Scan and Replace” a String in MYSQL
(Note the AS400-ish wording of that title).
Big Note: Be very careful of serialized data!!!!
Thanks to http://www.mydigitallife.info/how-to-find-and-replace-text-in-mysql-database-using-sql/ for these little pieces of code.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string)
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string');
update wp_posts set post_content = replace(post_content, 'http://domain.com/blog/', 'http://domain.com/')
The above statement will replace all instances of 'http://domain.com/blog' to 'http://domain.com/' in the field of post_content of wp_posts table.Read More...