Let's consider the following example. Say I have a table column called N.Note and it contains the string:
Veg: Lettuce 200 ¶ Fruit: Oranges 200 ¶ Dairy: Milk 300 ¶
This string is not constant and always changes positions. I would like select 'Oranges 200' . How can I edit this line below:
SUBSTR(N.NOTE, INSTR(N.NOTE, 'Fruit:')+6, 18) as Substring
As the string after orange ends with an ¶, you can chec for4 the position of that character after fruit comes.
as your last entry also contains and ending character
i added
LENGTHadditional so that you only need to exchange the category, the rest makes the query then automatically.Last You can add a
TRIMbecause there will be some spaces too muchdb<>fiddle here