Replaces all occurrences of the
<pattern> substring within the
<string> with the
REPLACE (<string>, <pattern>, <replacement>)
| ||The original string that will be searched for instances of the |
| ||The substring to be searched and replaced in the string.|
| ||The substring to replace the original substring defined by |
In the example below, “hello” in “hello world” is replaced with “nice”.
SELECT REPLACE('hello world','hello','nice') AS res;
In this example below, “world” is replaced by an empty string.
SELECT REPLACE('hello world',' world','') AS res;
In this following example, the substring “hi” is not found in the original string, so the string is returned unchanged.
SELECT REPLACE('hello world','hi','something') AS res;