Link Search Menu Expand Document


Replaces all occurrences of the <pattern> substring within the <string> with the <replacement> substring.


REPLACE (<string>, <pattern>, <replacement>)
Parameter Description
<string> The original string that will be searched for instances of the <pattern>.
<pattern> The substring to be searched and replaced in the string.
<replacement> The substring to replace the original substring defined by <pattern>. To remove the <pattern> substring with no replacement, you can use a empty string '' as the replacement value.


In the example below, “hello” in “hello world” is replaced with “nice”.

	REPLACE('hello world','hello','nice') AS res;

Returns: nice world

In this example below, “world” is replaced by an empty string.

	REPLACE('hello world',' world','') AS res;

Returns: hello

In this following example, the substring “hi” is not found in the original string, so the string is returned unchanged.

	REPLACE('hello world','hi','something') AS res;

Returns: hello world