A simple introduction to MySQL replace

Source: Internet
Author: User

Today classmate Discuz upgrade appears the primary key duplication, resulting in data insertion unsuccessful problem, and then looked up, said the method is to replace insert into with replace into, and then the replace into to the query, the following to do a brief introduction

1. Replace into

replace into is similar to insert, except that replace into first attempts to insert data into the table, 1. If you find that this row of data is already in the table (judging by a primary key or a unique index), the row data is first deleted and then the new data is inserted. 2. Otherwise, insert the new data directly.

2. Replace (object,search,replace)

the substitution of strings, for example:

Replace the AA in the Name field in the Tables table with BB and save to the database.

A simple introduction to MySQL replace

Related Article

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.