Skip to content
Advertisement

remove extra “WWW_” using sql SUBSTRING [closed]

In the Name_code column, we have these types of

WWW_XX_YYYY
XX_YYYY
XX_E100
XX_MESE
WWW_XX_MESE
WWW_XX_TECH

I want O/P the value like this

XX_YYYY
YYYY
E100
MESE
XX_MESE
XX_TECH

SUBSTR(Name_code,4, length(Name_Code)-3) i tried this but no result

How will do That?

Advertisement

Answer

You can use instr to find the index of the first underscore (_), and then substr from the character after that to the end of the table:

SELECT SUBSTR(mycol, INSTR(mycol, '_') + 1)
FROM   mytable
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement