If I have 2 tables:
A B
joe 1
joe 2
kevin 3
B C
1 1
1 2
1 3
2 2
2 3
3 3
What is the best way to get the subgroups when I search for column A?
i.e. for joe, i want to return 1:{1,2,3} and 2:{2,3}.
I know that I can iterate through multiple SELECT * FROM queries, but is there a way to do it in one query?
As a followup,
If I had a third table,
C D
1 x
2 y
3 z
How do I table 2 and table 3 together and then group by B?
I tried
select
tbla.id, tbla.name, group_concat(tblb.value)
from tbla
left join tblb
on tbla.id = tblb.a_id
group by tbla.id
left join tb1c
on tb1b.id=tb1c.id
and it does not seem to work
group_concatE.g.