So i have this table in mysql
x
Table - My_table
----------------------
Name GameAccount
peter peterGamer
peter peter2
peter petergaming
what I want to do is to join all the names that has the same value and transform into only one. How can i achieve that ?
example :
Name GameAccounts
peter peterGamer
peter2
peterGaming
Advertisement
Answer
For a single row, you can use group_concat()
:
select name, group_concat(gameaccount separator ' ') as gameaccounts
from my_table t
group by name;
You can adjust the separate to be what you want. The default is a comma.