1

a field is a varchar, i want to replace a sub string of this field.

ab123fg => ab456fg

the above is just a example. just like the sub string to be replaced.

1
  • how do you identify which part of your string needs replacing? Is it the 1st set of numbers? or characters 3,4,5 or something else? Commented May 10, 2012 at 19:20

1 Answer 1

4

http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace

REPLACE(str, 'ab123fg ', 'ab456fg')

EDIT:

MySQL doesnt have a find and replace regex function, maybe have a look at UDFs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.