The following UPDATE statement executes the replace test in www.test.com with ABC
UPDATE table name SET field name = replace (field value before substitution, ' replace keyword ', ' replace keyword ') WHERE field name REGEXP "field value before replace";
Example:
| The code is as follows |
Copy Code |
UPDATE Test SET Url= REPLACE (' www.test.com ', ' Test ', ' abc ') WHERE URL REGEXP "www.test.com"; |
If in the record, there are similar
Www.test.com
Www.test1.com
Www.test2.com
To turn these records into Www.abc.com, execute the SQL statement as follows
| The code is as follows |
Copy Code |
UPDATE Test SET Url= REPLACE (' www.test.com ', ' Test ', ' abc ') WHERE url REGEXP ' ^ (www.test) '; |
is very flexible, but there are very complex situations, regular efficiency is not necessarily higher than other methods, not necessarily to die holding a tree, and sometimes try new methods may learn more things.