CopyCode The Code is as follows: Update dede_addonsoft set dxylink = Replace (dxylink, '.zip ', '.rar') where aid> 45553;
Copy codeThe Code is as follows: Update 'table _ name' set field = replace(field,'.rar','.7z ');
Table_name: name of the table to be queried,
Field: field name in the table,
Replace(field,'.rar', '.7z');: Regular Expression matching. Replace. rar in the field with. 7z.
MySQL Regular Expression replacement, character replacement method
The two SQL statements are both character replacement and easy to use.
Update comment set url = If (URL Regexp 'test .yahoo.com.cn ', replace (URL, 'www1 .sohu.com', 'www .sina.com '), replace (URL, 'www2 .yahoo.com ', 'www .sina.com ') where 1 = 1;
Update comment set author_url = Replace (author_url, 'sohu ', 'sina') Where author_url Regexp 'www .sohu.com ';
Replace string with the MySQL replace Function
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 ')