3
votes

I have a field in my table like this:

fox,cat,bear,horse,dog

With FIND_IN_SET I can find if the value is in that string and get back the position of it. There is a way to get value of a determinate position?

for example:

position 3 = bear
position 2 = cat
1

1 Answers

4
votes

You can use substring_index twice in this way (change 2 to whichever item you want to extract):

select substring_index(substring_index(col, ',', 2), ',', - 1)
from t

Demo