Replace SQL statements with mysqlupdate Regular Expressions

Source: Internet
Author: User
If you need to replace SQL statements with mysqlupdate regular expressions, refer.

If you need mysql update Regular Expression replacement SQL statements, refer to it.

The following update statement replaces test in www.test.com with abc.


UPDATE table name SET field name = REPLACE (REPLACE the previous field value, 'replace the previous keyword ', 'replace the previous keyword') WHERE field name REGEXP "REPLACE the previous field value ";


Example:

The Code is as follows:
UPDATE test SET
Url = REPLACE ('www .test.com ', 'test', 'abc ')
WHERE url REGEXP "www.test.com ";


If there is a similar
Www.test.com
Www.test1.com
Www.test2.com
To change all these records to www.abc.com, execute the following SQL statement:

The Code is as follows:

UPDATE test SET
Url = REPLACE ('www .test.com ', 'test', 'abc ')
WHERE url REGEXP '^ (www. test )';

Regular Expressions are very flexible, but in complex cases, the efficiency of regular expressions is not necessarily higher than that of other methods, and it is not necessarily necessary to hold a tree, sometimes you may learn more by trying a new method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.