I'm making a blog. I have 2 tables, one for posts
and the other for categories
.
I want to display the category name, category date and the number of posts in each category. I have problems to display the number of posts in each category.
In posts
table I have a column called cat_id
which is equal to category.id
I have these 2 MySQL queries:
mysql_query("select Count(posts.id) as NumberOfPosts, cat_id from posts group by cat_id");
And
mysql_query("select name, date from categories");
I don't know how to have combine these two queries into one query. I'm using PHP.