brianbehrens Posted October 31, 2007 Share Posted October 31, 2007 I'm a little unclear exactly how to use this, or if I can even use thing in conjunction with pulling out the proper amount of data needed. Here's my current query $sql = "SELECT * FROM photo_albums pa LEFT JOIN photos p ON pa.pa_id = p.album_id ORDER BY pa.pa_id DESC"; I want to pull out all of my albums and in turn find out all the associated photos with that album. I'm interested in finding out how many photos are in each album. I can do it in PHP based on the current query, but after doing some reading it seems I could do this in mySQL. I'm just unclear if it can be done in the same query or if it would take another one all together? Thank you. Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 31, 2007 Share Posted October 31, 2007 $sql = "SELECT count(photos),* FROM photo_albums pa LEFT JOIN photos p ON pa.pa_id = p.album_id group by album ORDER BY pa.pa_id DESC "; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.