In MySQL, I have a text column with "bla bla bla YYY=76767 bla bla bla".
I need to cut the number 76767.
How can I do it in SQL?
You can use
select substring_index(substring(mycol, instr(mycol, "=")+1), " ", 1)
to get the first token after the =
.
This returns 76767
.
This works in two steps :
substring(mycol, instr(mycol, "=")+1)
returns the string starting after the =
and
substring_index( xxx , " ", 1)
get the first element of the virtual array you'd got from a split by " ", and so returns the first token of xxx.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With