Skip to content

REPLACE

  • str: This parameter refers to the source string where the search will be conducted.
  • from_str: This parameter refers to the sub-string which is to be replaced. In other words, this is the target text within the ‘str’ that will be substituted.
  • to_str: This is the parameter that contains the replacement text. Any instances of ‘from_str’ in the ‘str’ will be replaced with this value.
SELECT REPLACE('SQL is fun', 'fun', 'fantastic');
'SQL is fantastic'

The REPLACE function is used here to replace the word “fun” with “fantastic” in the string “SQL is fun”. The new string “SQL is fantastic” is then returned.