When we are processing in bulk MySQL DatabaseWhen the time comes, you will often encounter situations where you need to batch replace some specific character content across multiple forms. When you encounter such situations, you cannot perform a search and replace operation one by one. This is when you need to use the batch replace character content MySQL command to perform the replacement operation. (Note: No translation was performed on the following terms: MySQL, batch replace, character content)
For example, when we encounter the following situation in our database:
| Name: area | |
|---|---|
| id | name |
| 1 | Yu Zhou |
| 2 | Yu County |
| 3 | Yu County |
| 4 | Yu County |
| 5 | Yu Zhou |
We want to translate the name field in“Yu Zhou Shi” 统一改为“Yu Zhou”You need to use the following command:
update `area` set `name` = replace(name, '市', '');
Alternatively, you can also use:
update `area` set `name` = replace(name, '禹州市', '禹州');
Actually, these two methods use the same command, just with a slightly different replacement method! Everyone in网站Data migration replacing domain name, orWebsite deployment SSL certificateAfter modifying the HTTPS domain prefix, you may need to use this command to perform batch replacement of database content.