MySQL Forums
Forum List  »  Newbie

Re: How to JOIN multiple tables and display multiple rows from each table?
Posted by: G Marshall
Date: July 30, 2007 05:06PM

Thanks for the response. I'm currently using print_r to dump the query output.

I noticed in your example, your database is set up as follows:

artists => albums => tracks

In my case, I have:

Members => Addresses (Members can have 0 or more Addresses)
Members => Contacts (Members can have 0 or more Contacts)

In your example, if you add an additional track, your query will will only produce one additional row.

But in my case, if I add an additional contact or address, the query will produce many more rows since all of the combinations of address / contact pairs are outputted. It would get even worse if I joined another table such as Accounts that had a Members => AccountNumbers relationship (Members can have 0 or more account numbers)

For example, member "Tim" has Addresses "red st", "white st" and "blue st" and Contacts "555-1212", "tim@tim.com"

My query will have produce:
Tim , red st , 555-1212
Tim , red st , tim@tim.com
Tim , white st, 555-1212
Tim , white st, tim@tim.com
Tim , blue st , 555-1212
Tim , blue st , tim@tim.com

If another "contact" is added such as "tim@otheremail.com", the query will produce these additoional 3 rows:
Tim , red st , tim@otheremail.com
Tim , white st, tim@otheremail.com
Tim , blue st , tim@otheremail.com

It seems like the row count will get very large very quickly. Is the only way to deal with this by using similar php code as you show in your example?

Thanks for the help. The link you provided was very helpful.

Options: ReplyQuote


Subject
Written By
Posted
Re: How to JOIN multiple tables and display multiple rows from each table?
July 30, 2007 05:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.