Replaces one or more occurrences of a specified string value with another specified value.

Syntax

REPLACE (stringToSearchWithin, stringToFind, newString)

Arguments

  • stringToSearchWithin: The string containing text to find and replace.
  • stringToFind: The substring, within stringToSearchWithin, which will be replaced.
  • newString: The new string, which will replace all occurrences of stringToFind.

Returns

  • The same data type as stringToSearchWithin

  • NULL if any arguments are NULL.

Examples

SELECT REPLACE('Washington', 'ing', '---')
FROM MYSQL.inventory.cust;

-- Returns
Wash---ton