how to get comma separated values in one column for multiple rows that have same id

929 Views Asked by At

before before

after after

tried few functions but didnt work

1

There are 1 best solutions below

0
Liutprand On

Some databases (like MySql or MariaDb) support a group_concat() function that can be used in conjunction with GROUP BY:

select
  id,
  group_concat(distinct value separator ',')
from table
group by id

Some other databases may have a similar function with a different name (STRING_AGG() for example), try to check your db documentation...