MySQL batch replacement is a feature that we often use. Sometimes, when the site contains sensitive words, it will cause us trouble. However, when the amount of information is large, it is unrealistic to search and modify an article.
It is easy to use MySQL for batch replacement. Released here for reference.
MySQL batch replace a specified field string statement
- UPDATE data table name SET
- Field name = replace (field name, 'replacement string', 'replace ')
- WHERE setting conditions;
-
For example, replace "Search Engine Optimization" In Wordpress articles with "search engine marketing", and replace the statement:
- UPDATE wp_posts SET
- Post_content = replace (post_content, 'search engine optimization', 'search engine marketing ');
-
You can also add replacement conditions in the statement. For example, you can only replace the content with a limited ID less than 200:
- UPDATE wp_posts SET
- Post_content = replace (post_content, 'search engine optimization', 'search engine marketing ')
- Where id <200;
-
You can set replacement conditions based on your needs.
MySQL string addition function usage example
Mysql query case
How to query duplicate records in MYSQL
How to Implement MySQL full-text Query
Example of the number of MySQL query results