SELECT p.posts_id, p.posts_title, COUNT( ph.photos_id ) FROM posts AS p, photos AS ph WHERE ( ph.photos_post_id = p.posts_id ) GROUP BY ph.photos_post_id ORDER BY p.posts_id DESC LIMIT 0 , 5