MySQL REPLACE() Function
Example
Replace the substring "SQL" with "HTML":
SELECT REPLACE("SQL Tutorial", "SQL", "HTML");
Try it Yourself »
Definition and Usage
The REPLACE() function replaces all occurrences of a specified string.
Note: The REPLACE() function performs a case-sensitive replacement.
Syntax
REPLACE(string, from_substring, to_substring)
Parameter Values
Parameter | Description |
---|---|
string | Required. The string |
from_substring | Required. The substring to find |
to_substring | Required. The replacement substring |
Technical Details
Works in: | MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23 |
---|
More Examples
Example
Replace the substring "A" with "B":
SELECT REPLACE("ABC ABC ABC", "A", "B");
Try it Yourself »
Example
Replace the substring "A" with "c":
SELECT REPLACE("ABC ABC ABC", "A", "c");
Try it Yourself »
Example
Replace the substring "a" with "c":
SELECT REPLACE("ABC ABC ABC", "a", "c");
Try it Yourself »