FAQ: Date, Number, and String Functions - Strings II


#1

This community-built FAQ covers the “Strings II” exercise from the lesson “Date, Number, and String Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

SQL: Table Transformation

FAQs on the exercise Strings II

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


#2

In this section the instructions say:

1. Any time enriched_flour appears in the ingredients list, we’d like to replace it with just flour . Apply this transformation and also be sure to remove the underscore in enriched_flour .

The solution button gives this:

SELECT REPLACE(ingredients,'enriched_',' ') as item_ingredients
FROM baked_goods;

My (“WRONG”) solution is this:

SELECT REPLACE(ingredients,'enriched_flour','flour') as item_ingredients
FROM baked_goods;

I feel that my answer is more correct than the solution provided for the following reason.
If any other ingredient in that column contains "enriched_" that will also be replaced.
For example if there was something like "enriched_chocolate" it will be changed to " chocolate" while the instructions say only to replace enriched_flour.

I know it is redundant to replace flour too, but it would yield more accurate results if you don’t know what each and every ingredient in that list is.

Maybe I’m not understanding the question correctly? But that’s my take on it.