Mateusz Ji
Mateusz Ji

Reputation: 59

mysql - merge cols into one row

I need to merge few columns into one row in mysql, separated by some char (; or dot), from:

Id              Item       Options

1               Charger       iphone
2               Car           black
3               Food          vege

into:

Items

"Charger; Car; Food"

Upvotes: 0

Views: 29

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269503

You are looking for group_concat(), presumably:

select id, group_concat(item separator '; ') as items
from t
group by id;

Upvotes: 3

Related Questions