Substitute “SQL” with “HTML”.
| SELECT REPLACE(“SQL Tutorial”, “SQL”, “HTML”); |
The REPLACE() function substitutes all instances of a substring within a string with a new substring. It’s important to note that this function performs a case-sensitive replacement.
| REPLACE(string, from_string, new_string) |
|
Parameter |
Description |
|
string |
Input required: The original string in which replacements will be made. |
|
from_string |
Input required: The substring that will be replaced within the original string. |
|
new_string |
Input required: The new substring that will replace occurrences of the specified substring within the original string. |
| Works in: | From MySQL 4.0 |
Substitute “X” with “M”.
| SELECT REPLACE(“XYZ FGH XYZ”, “X”, “M”); |
Substitute “X” with “M”.
| SELECT REPLACE(“XYZ FGH XYZ”, “X”, “m”); |
Replace occurrences of “x” with “m”.
| SELECT REPLACE(“XYZ FGH XYZ”, “x”, “m”); |