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?