Method for updating some data in a Mysql field _ MySQL

Source: Internet
Author: User
Method for updating part of data in a Mysql field bitsCN.com


How to update some data in a Mysql field

Mysql updates some data in the field in the first case:

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

Start from 1 character of A and add 'BBB 'to a. If the original value of A is '123aaa', it is updated to '123bbb.

What if we want to replace 1 in field A with 2?

For example, if a = 2211 is to be replaced with 2222, it means to replace 1 with 2.

Write the SQL statement as follows: update table set a = REPLACE (a, '1', '2 ');

BitsCN.com

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.