Jump to content

Recommended Posts

I'm looking at a way to do a query where a music entry has at least one published value in another table.  My mysql knowledge is ropey at best  ::) but learning all the time anyway.

 

Here's what I've tried :

 

 $q = "SELECT COUNT( a.id )
            FROM #__music_artists a
            LEFT JOIN #__music_albums al ON a.id = al.artist_id
            WHERE a.surname LIKE '" . $id . "%'
            AND 1 IN (al.published)";

 

Which doesn't work.  Basically my problem is is that each artist may have published and unpublished albums, so I need to check the albums table to see if there is at least one published album amongst what could be loads of unpublished albums, or the opposite. 

 

I just need the published to return true, and let the artist do the counting for calculating a table display.

 

Any ideas/help on this?  I looked at LEAST() but that did nothing as well.

 

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.