Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Concatenation
Simple text functions
Modifying strings
17. The REPLACE() function
Summary

Instruction

Great! You can also replace parts of a string with anything you want using the REPLACE() function. It works like this:

REPLACE(string, substring_to_change, new_substring)

This searches string and, if it finds the substring_to_change, replaces substring_to_change with the text in new_substring. Let's try it!

SELECT REPLACE('young man', 'young', 'old');

In the above example, the function will look for 'young' in the string 'young man' and will replace it with 'old'. As a result, we'll get 'old man'. Of course, you can provide a column name instead of an actual text.

Let's practice using this function!

Exercise

For the slogan with an ID of 1, replace the word 'Feel' with 'Touch'. Show the slogan's original text and the updated text as the updated_text column.

Stuck? Here's a hint!

Use the following expression:

REPLACE(text, 'Feel', 'Touch')