How many times does MySQL control replace replacement?

Source: Internet
Author: User
I want to replace "ABC is abc" with "123 is ABC", that is, to find out the first ABC to replace the 123,mysql command should be how to write?

UPDATE Data SET body=replace (body, ' ABC ', ' 123 '); When I use this command, I will replace all ABC with 123, do not know how to control the number of replacements, please expert advice.
hemu780924 Brother's code, although it can be used, but there is a fatal flaw,

For example "123 is ABC", if you want to find XYZ and replace OPQ, because "123 is ABC" can not find XYZ, then the command will be "123 is ABC" before inserting XYZ, this is not what I want Ah!



Concat
SUBSTRING (Body, 1,position (' ABC ' in body)-1),
' 123 ',
SUBSTRING (body, position (' abc ' in body) +length (' abc '))) where the body like '%abc% '
Here to replace the first ABC, without ABC will not replace

How many times does MySQL control replace replacement?

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.