We often use the MySQL replace function. The following describes the usage of the MySQL replace function in detail, hoping to enlighten you in learning the MySQL replace function.
I recently studied CMS and used mysql replace function during data conversion. Here I will briefly introduce it.
For example, you want to replace the abc of the f1 field in Table tb1 with def.
UPDATE tb1 SET f1 = REPLACE (f1, 'abc', 'def ');
REPLACE (str, from_str, to_str)
All the from_str strings in the str string are replaced by to_str, and the following string is returned:
Mysql> select replace ('www .mysql.com ', 'w', 'ww ');
-> 'Wwwwww .mysql.com'
This function is multi-byte secure.
Example:
UPDATE 'dede _ addonarticle' SET body = REPLACE (body,
'</Td> ',
'');
UPDATE 'dede _ addonarticle' SET body = REPLACE (body,
'</Tr> ',
'');
UPDATE 'dede _ addonarticle' SET body = REPLACE (body,
'<Tr> ',
'');
UPDATE 'dede _ archives 'SET title = REPLACE (title,
'Dayang news -',
'');
UPDATE 'dede _ addonarticle' SET body = REPLACE (body,
'../../../../../../',
'Http: // special.dayoo.com/meal /');
Mysql replace
Usage 1. replace intoreplace into table (id, name) values ('1', 'A'), ('2', 'bb ')
This statement inserts two records into the table.
2. replace (object, search, replace)
Replace all search objects with replaceselect replace ('www .163.com ', 'w', 'ww') ---> www wWw.163.com
For example, replace aa in the name field of the table with bbupdate table set name = replace (name, 'AA', 'bb ')
How to quickly enable MySQL slow log query
How to query duplicate records in MYSQL
How to Implement MySQL full-text Query
Example of the number of MySQL query results
How to query intermediate records in MySQL