user3473915
user3473915

Reputation:

FIND distinct value from comma separated single string

I have a table like this and I want to select distinct value in single column:

  ID        Value

  1       13245|43558

  2       45961|5051

  3       43558| 5059

I need output Like this:

13245,43558,45961,5051,5059

Upvotes: 0

Views: 3698

Answers (2)

echo_Me
echo_Me

Reputation: 37233

try that:

  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

Upvotes: 2

Up_One
Up_One

Reputation: 5271

Try this query :

SELECT GROUP_CONCAT(distinct(Value)) from table;

Upvotes: 0

Related Questions