Relational database help

Thanks for all the help guys. I have settled on this solution, but have learnt a lot from this thread!

PHP:
SELECT DISTINCT song.song_id, song.title
FROM song

INNER JOIN (SELECT song_id, COUNT(*) FROM song_genre 
WHERE genre_id IN ('1','2') 
GROUP BY song_id HAVING COUNT(*) = 2) genre1 ON genre1.song_id = song.song_id

INNER JOIN (SELECT song_id, COUNT(*) FROM song_instrument 
WHERE instrument_id IN ('1','2') 
GROUP BY song_id HAVING COUNT(*) = 2) instrument1 ON instrument1.song_id = song.song_id
 
Back
Top Bottom