Reputation: 35
I got list of database.
**NAME**
OEE_LINE_ABC
OEE_LINE_ABCD
OEE_LINE_QWERTYUIOP
OEE_LINE_zxcvbd
I need to grab the Name
that after OEE_LINE_
. But it does not standardize how many characters. What I get from google is fix how many characters.
Example :
SUBSTR(Name,10,3)
Result: 'ABC'
If I use above substr, it able to grab the 1st value (OEE_LINE_ABC
) without problem, when comes to 2nd value, there's a problem because above substr only can retrieve 3 characters.
Expected result:
the SQL statement able to grab values that after OEE_LINE_
Result(return name without the OEE_LINE_
):
Name = ABC
Name = ABCD
Name = QWERTYUIOP
Name = zxcvbd
Any related post to share and answer?
Upvotes: 1
Views: 257
Reputation: 2393
If you need the rest of the string, just specify the start position:
SELECT SUBSTR(name, 10)
Upvotes: 1
Reputation: 1269823
I would suggest looking for the last '_
' and taking the string from there:
select substr(name, length(name) - instr(reverse(name), '_') + 2)
Upvotes: 2