Welcome Guest, Not a member yet? Register   Sign In
SQL Count Query
#1

[eluser]underskor[/eluser]
I am trying to retrieve all categories, and the number of posts in each category.
Code:
SELECT COUNT(blog_entries.post_id) AS post_count,
blog_categories.category_id, blog_categories.category_title, blog_categories.category_desc
FROM blog_categories, blog_posts
WHERE blog_posts.category_id = blog_categories.category_id
GROUP BY blog_categories.category_title
This works, but it only fetches the rows of categories which have posts under them. How do I return the categories which are empty as well?

Thanks


Messages In This Thread
SQL Count Query - by El Forum - 01-12-2009, 10:52 PM
SQL Count Query - by El Forum - 01-12-2009, 11:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB