Skip to content
Advertisement

Append values of other records for a distinct values of a column

if my database table is like:

  name    col_2
 Manish  352-103
 Manish  342-123
 ganesh  362-111
 ganesh  789-232
 abcd    456-231
 abcd    047-234

now i want it as:

  name      col-2
 Manish  352-103, 342-123
 ganesh  362-111, 789-232
 abcd    456-231, 047-234

(I need distinct values of name and col-2 values must appended for the each distinct value of name) Both column values are of type text

Advertisement

Answer

This solved the requirement in MySQL

select name, group_concat(col-2) from dbo.sample group by name

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement