A Brief Introduction to MySQL replace, mysqlreplace

Source: Internet
Author: User

A Brief Introduction to MySQL replace, mysqlreplace

Today, when I upgraded discuz, I encountered a primary key repeat, which caused the data insertion to fail. Then I searched for the problem. The method described here was to replace into and then query replace, the following is a brief introduction.

1. replace

Replace into is similar to insert. The difference is that replace into first tries to insert data into the table. if this row of data already exists in the table (determined based on the primary key or unique index), delete the row of data and insert new data. 2. Otherwise, insert new data directly.

2. replace (object, search, replace)

String replacement, for example:

Update table set name = replace (name, 'AA', 'bb ')
Replace aa in the name field of the table with bb and save it to the database.


Use of the Mysql replace () function

Yes.
Updat table set 'zd1 '= REPLACE ('zd1', '#', 'logistic ') WHERE 'zd1' LIKE '% # %'

Mysql replace Problems

I suggest you look at the replace into statement to implement your function!

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.