If the maximum limit on the number of languages in a set, you can pull out all the first elements, elements, third elements, etc. and combine them together. Here is an example that pulls any first or second element from a set of languages and combines them:
select distinct substring_index(langs, '-', 1) as lang
from people where langs != ''
union
select distinct SUBSTRING_INDEX(SUBSTRING_INDEX(langs, '-', 2), ',', -1)
from people where LENGTH(langs) - LENGTH(REPLACE(langs,',','')) + 1 > 1
Demo: http://www.sqlfiddle.com/#!2/b86f2/1
, , people.langs like '%EN%' :
select
lang,
count(case when people.langs like concat('%',langs.lang,'%') then 1 end) as count
from people,
(
select distinct substring_index(langs, '-', 1) as lang
from people where langs != ''
union
select distinct SUBSTRING_INDEX(SUBSTRING_INDEX(langs, '-', 2), ',', -1)
from people where LENGTH(langs) - LENGTH(REPLACE(langs,',','')) + 1 > 1
) langs
group by langs.lang
order by langs.lang
:
LANG COUNT
DE 2
EN 4
RU 2
: http://www.sqlfiddle.com/#!2/b86f2/5