-1

I have a table like this:

id  value  
1   a   
1   b   
2   c   
2   d   
2   e   

I want to combine rows with the same ids into one,here is what i want as result:

id  value  
1   a b 
2   c d e   
Mr Yar
  • 329
  • 1
  • 3
  • 9
  • Possible duplicate of [Can I concatenate multiple MySQL rows into one field?](http://stackoverflow.com/questions/276927/can-i-concatenate-multiple-mysql-rows-into-one-field) – Pmpr.ir Feb 28 '17 at 08:08

1 Answers1

4

try this

select id,group_concat(value) as value from tb_name group by id;

if you want space instead ',' then try below query

select id,replace(group_concat(value), ',' ,' ') as value from tb_name group by id;
denny
  • 1,914
  • 2
  • 14
  • 19