sql - Is there a FIND_IN_SET by index in MySQL? -


i know storing lists strings not wise, have deal export data stored way. know find_in_set function, returns index of string in list:

select find_in_set('bar', 'foo,bar,baz'); -- selects 2 

is there built-in function (or combination of functions) string in particular index of list? i'm looking this:

select in_set_at_index(2, 'foo,bar,baz'); -- selects 'bar' 

i'd avoid split-like function makes list separate table, if possible.

substring_index() can this, sort of:

mysql> select substring_index(substring_index('foo,bar,baz', ',', 2), ',', -1) middle_one; +------------+ | middle_one | +------------+ | bar        | +------------+ 

Comments