Jump to content

Trying to find results if at least a value


richrock

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.

 

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.