我有一个这样的表,我想在单列中选择不同的值:
ID Value
1 13245|43558
2 45961|5051
3 43558| 5059
我需要这样的输出:
13245,43558,45961,5051,5059
最佳答案
尝试:
select group_concat(distinct trim(substring_index(substring_index(value, '|', n.n), '|', -1)) separator ',' ) as `values`
from table1 t
cross join (select 1 as n union all select 2 ) n
order by `values`
DEMO HERE
关于mysql - 从逗号分隔的单个字符串中查找不同的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22721032/