Mysql two ways to update some of the data in a field _mysql

Source: Internet
Author: User
Tags mysql update
MySQL update some of the data in the field in the first case:
Copy Code code as follows:

Update tab SET A = concat (substring (a,1,3), ' BBB ');


Starting with the 1 characters of a, 3 characters, plus ' BBB ', and writing to a, if a original value is ' 123aaa ', then ' 123BBB ' after the update.

What if we were to replace 1 of the included in the value of a field a with 2?
For example: a=2211, now to replace 2222, is to replace 1 to 2
The SQL statement writes this:
Copy Code code as follows:

Update table Set A=replace (A, ' 1 ', ' 2 ');
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.