bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL REPLACE() Function

Concept visual

MySQL REPLACE() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Replace "SQL" with "HTML":

SELECT REPLACE("SQL Tutorial", "SQL", "HTML");

Definition and Usage

The REPLACE() function replaces all occurrences of a substring within a string, with a new substring.

Note:

Formula

This function performs a case - sensitive replacement.

Syntax

Replace(

string, from_string, new_string )

Parameter Values

Parameter

Description string

Required. The original string from_string Required. The substring to be replaced new_string Required. The new replacement substring

Technical Details

Works in:

From MySQL 4.0

More Examples

Example

Replace "X" with "M":

SELECT REPLACE("XYZ FGH XYZ", "X", "M");

Example

Replace "X" with "m":

SELECT REPLACE("XYZ FGH XYZ", "X", "m");

Example

Replace "x" with "m":

SELECT REPLACE("XYZ FGH XYZ", "x", "m");

Previous

❮ MySQL Functions

Next

Previous

MySQL REPEAT() Function

Next

MySQL REVERSE() Function