我有一个这样的表,我想在单列中选择不同的值:
ID Value
1 13245|43558
2 45961|5051
3 43558| 5059
我需要输出像这样:
13245,43558,45961,5051,5059
答案 0 :(得分:1)
试试:
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`
答案 1 :(得分:0)
尝试此查询:
SELECT GROUP_CONCAT(distinct(Value)) from table;