I think I have reached my current limits with Left Joins. Currently I have the following MySQL query which is working fine:
SELECT blog.id, blog.title, blog.post, blog.date, blog.time,
count(blog_comment.b_id) CommCount
FROM blog
LEFT JOIN blog_comment ON blog.id = blog_comment.b_id
GROUP BY blog.id
ORDER BY id DESC
LIMIT $start_blog, $blog_per_page
This will display a list of blog posts and display the number of comments each post has, nice and simple.
For the admin panel I want to display the Blog Posts followed by the number of comments on each post and then a new field which displays the number of pending comments.
The pending comments are stored in blog_comment.pending (1 for pending, 0 for not pending)
I just can’t seem to get my head around how to do it.
Try this:
Sum will simply add up the number of pending flags…