Step 8/9: Replace enriched_flour with just flour


#1

I tried the following scripts:

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

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

SELECT id, REPLACE(REPLACE(ingredients,'enriched_flour','flour'),'_',' ') as item_ingredients
from baked_goods;

SELECT id, REPLACE(REPLACE(ingredients,'enriched',''),'_',' ') as item_ingredients
from baked_goods;

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

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

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

SELECT REPLACE(REPLACE(ingredients,'enriched',''),'_',' ') as item_ingredients
from baked_goods;

But none of the scripts was accepted.


Strings II - Manipulate Many Criteria
#2

@antoninslejska,
The required solution

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

========================================================================

IMHO
the following would be valid, as the Instructions where unclear..........

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

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

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

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

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

========================================================================

The following select's would lead to
brown_sugar becoming brownsugar

SELECT id, REPLACE(REPLACE(ingredients,'enriched',''),'_',' ') as item_ingredients
from baked_goods;

SELECT
id, REPLACE(REPLACE(ingredients,'enriched_flour','flour'),'_',' ') as item_ingredients
from baked_goods;

SELECT REPLACE(REPLACE(ingredients,'enriched',''),'_',' ') as item_ingredients
from baked_goods;


#3

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

Is actually the correct response. There should be no space in between the ''. Otherwise, the entry would be ' flour' instead of 'flour'.
But thank you @leonhard.wettengmx.n for pointing me in the right direction


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.