Explain REPLACE() Function in SQL?

REPLACE() function could be used to replace all presence of a substring within a string, with a new substring. REPLACE() function is case-sensitive.

Syntax :

SELECT REPLACE(string, from_string, new_string)

Parameter string is used to replace the original string from_string to be new_string.

Example: In this example, you will see how you can replace any string value with a new string value by using the replace function.

Let’s consider an example where “MySQL” replace with an “HTML” value. Below given is the replace function values.

Replace “MySQL” with “HTML”

Now, you will see how you can read the replace values.

SELECT REPLACE("Hello World", "World", "People");

Output :

Hello People