Date, Number, and String Functions

Strings II

Another useful string function in SQL is REPLACE():


The function returns the string string with all occurrences of the string from_string replaced by the string to_string.

For example in baked_goods, there is a column named ingredients. The ingredients strings are formatted with underscores, such as baking_soda and vanilla_extract. To make these values more readable, we might like to replace the underscores with spaces. We can do so by using the following query:

SELECT id, REPLACE(ingredients,'_',' ') as item_ingredients
from baked_goods;
Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.