Reputation: 21
Using mysql I need to find the position of the 1st occurrence of any alphabet in a sub string.
For example if my string is like 123456A12345
then I need to find the position of A.
My main goal is to get all the digits just before the alphabet.
Thanks in advance.
Upvotes: 2
Views: 155
Reputation: 1269973
If you want to get all the digits, just convert the string to an integer by adding 0:
select '12345abc'+0
returns 12345.
This does not handle leading 0s. And, it won't work for any length expression, but it may solve your problem quickly.
Upvotes: 2