MySQL REPLACE() function can replace all the occurrences of a substring with another substring within a string.
Syntax
REPLACE(str, find_string, replace_with)
Here
- Str is a string which have the substring.
- Find_string is a substring which is present one or more times within the strung str.
- Replace_with is a substring which will replace every time it finds find_string within str.
Example
mysql> Select REPLACE('Ram, My Name is Ram', 'Ram', 'Shyam'); +------------------------------------------------+ | REPLACE('Ram, My Name is Ram', 'Ram', 'Shyam') | +------------------------------------------------+ | Shyam, My Name is Shyam | +------------------------------------------------+ 1 row in set (0.00 sec)