0

Hi I am a bit rusty with SQL, not used it for about 8 years so would appreciate a bit of help.
I have three tables, normalised,

organisation, stores org_name and org_id
ativities stores activity_name and ativity_id
org_activity stores org_id and activity_id

I need to get a list that contains each organisation name distinctly along with a list of all the activities associated with it. Try as I might I just can't get my head round it, any pointers would be greatfully received.
Thanks
Julie

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jward50
0

Mysql has a nifty function for it: group_concat
Like in

select org_name, group_concat(activity_name)
from organisation o, activities a, org_activity oa
where o.org_id=oa.org_id
and oa.activity_id=a.activity_id
group by o.org_id
;

(Code not tested)
Alternatively you may look at the various JOIN syntax varieties of MySQL.

0

Wow thanks a million, I have never come across group_concat and it does the trick.
Thanks you so much for all your help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.