MySQL - Select Club Name and list all members in one query? -
- i have "clubs" table , "members" table
- i'd query return club name (clubs.name) , each member's nickname (members.nickname)
i can them using inner join,
select clubs.name `club name`, members.nickname `member handle` clubs inner join members on clubs.club_id = members.club_id
but shows club.name field each member.nickname.
| club name | member handle | ------------------------------- | club yellow | jim-bob | | club yellow | clem | | club yellow | mustache pete | | club green | ladyhawke | | club green | rosie |
is @ possible receive result so?
| club name | member handle | ------------------------------- | club yellow | jim-bob | | | clem | | | mustache pete | | club green | ladyhawke | | | rosie |
thanks
no in mysql can not generate result this, need use application level it. can format data i.e. member-handle
comma-separated values
select clubs.name `club name`, group_concat(members.nickname) `member handle` clubs inner join members on clubs.club_id = members.club_id group clubs.name
Comments
Post a Comment