Mysql Tutorial: Database character replacement and replace function usage _ MySQL

Source: Internet
Author: User
Mysql Tutorial: Database character replacement and replace functions can be used when you want to REPLACE the content of a field in the database:

Syntax:

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> selectREPLACE ('www .mysql.com ', 'W', 'WW ');

-> 'Wwwwww .mysql.com'

This function is multi-byte secure.

Example:

UPDATE 'dede _ addonarticle' SET body = REPLACE (body,

'',

'');

UPDATE 'dede _ addonarticle' SET body = REPLACE (body,

'',

'');

UPDATE 'dede _ addonarticle' SET body = REPLACE (body,

'',

'');

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 .webjx.com ', 'W', 'WW') ---> www wWw.webjx.com

For example, replace aa in the name field of the table with bbupdate table set name = replace (name, 'AA', 'BB ')

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.