I need help with a substring_index query capable of selecting both negative and positive numbers from a string.
Two example strings:
-25-10/-23-10/-22-10
25-10/23-10/22-10
In the first string I would like -22
and the second string 22
to be returned.
The following works when the result is positive:
SET @test := '25-10/23-10/22-10';
SELECT substring_index(substring_index(@test,'/',-1),'-',1);
returns 22
I have not been able to figure it out for negative, let alone work for both positive and negative.
Any ideas?