Jump to content

MySQL Query help needed


pedro84

Recommended Posts

Hi!

 

I got three tables: musicians, bands and musicians_bands. In musicians and database I'm storing all musicians and bands data. I musicians_bands table I store informations about bands of specifics musicians they were members.

 

Now question. I got following query:

$query =  mysql_query("SELECT * FROM musicians, bands, musicians_bands where (musicians_bands.id=musicians.id) and (musicians_bands.id=bands.id) group by bands.id");

 

I returns for me:

Artist 1 - Band 1
Artist 2 - Band 2
Artist 1 - Band 3

 

How to force it to display:

Artist 1 - Band 1, Band 3
Artist 2 - Band 2

?

Link to comment
https://forums.phpfreaks.com/topic/125654-mysql-query-help-needed/
Share on other sites

What kind of tips are you wanting?  You seem to already have a query and a method for displaying it.  Just change your query to order it by artists instead, and add a condition in your loop that lists the stuff out to make a new line if the currently fetched row's artist changes...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.