Jump to content

Matching multiple row data from one table with a single row of another table


KitCarl

Recommended Posts

Reading the responses to questions on this forum and having a few posts answered has been a fantastic learning tool! I still know almost nothing but I'm making more progress than I was from the manuals. After reading several posts and experimenting I had a big  ;D after figuring out how to left join multiple tables together create a list from more normalized tables. Anyhow that works fine if I want to create a list of people who belong to each club, but not if I want to list the people and which club(s) they are members.

 

In simple terms:

I have Person table P with P.personid, P.first name, etc.

I have Club table C with C.clubid, C.name, etc.

I have clubMember table CM with CM.clubMemberID, CM.personid , CM.clubID

 

Each person can belong to more than one club so how do I write a query to give me the Name info from the Person table once, but return all C.name's that match the P.personID so I can display it as

 

Name                                      Clubs

Joe Whatever                                Club A, Club B, Club C

 

NOT

 

Name                                            Clubs

 

Joe Whatever                                              Club A

Joe Whatever                                              Club B

Joe Whatever                                              Club C

 

Do I need a sub-query or is this solved with PHP?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.