1. Learn
  2. /
  3. Courses
  4. /
  5. Reporting in SQL

Exercise

Replacing and removing substrings

The REPLACE() function is a versatile function that allows you to replace or remove characters from a string. The syntax is as follows:

REPLACE(fieldName, 'searchFor', 'replaceWith')

Where fieldName is the field or string being updated, searchFor is the characters to be replaced, and replaceWith is the replacement substring.

In this exercise, you will look at one specific value in the countries table and change up the format by using a few REPLACE() functions.

Instructions 1/2

undefined XP
    1
    2
  • Create the field character_swap that replaces all '&' characters with 'and' from region.
  • Create the field character_remove that removes all periods from region.