I have a Table member with member_id
, member_name
, club_name
, region
, zone
, email
as fields.
I am using the MySQL group_concat
function like
SELECT group_concat(distinct m.email
SEPARATOR ', ' ) from member m group by m.club_name
This is working fine. But I would like to be able to group_concat
on other fields without creating additional queries.
Is it possible to supply the other fields as parameter?
member_id member_name club_name region zone email
1 member1 A 1 1 email1@example.com
2 member2 A 1 1 email2@example.com
3 member3 B 1 1 email3@example.com
4 member4 C 1 2 email4@example.com
5 member5 D 2 1 email5@example.com
**group by club**
email1@example.com,email2@example.com
email3@example.com
email4@example.com
email5@example.com
**group by region**
email1@example.com, email2@example.com, email3@example.com, email4@example.com
email5@example.com
**group by zone**
email1@example.com, email2@example.com, email3@example.com
email5@example.com
Say every Region has 3 Zones, every zone has more than one club. Now how can I get emails which can be grouped or related to Region, Zone or Club for that matter?