Reputation: 17383
I have a table like this:
title - description
A AA
B B
A AAA
B BBBBB
now I would like to have a json like this:
A
AA
AAA
B
B
BBBB
Is it possible to use one query?
Upvotes: 0
Views: 168
Reputation: 39497
Based on your sample data, you can use group by
with group_concat
to get comma separated value for each title:
select title,
group_concat(description)
from your_table
group by title;
Upvotes: 1