Jump to content

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

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.