How to query this situation?
I wrote a question a few hours ago about many to many queries. mellamokb suggested:
How about list the categories, and how many posts in each category, sorted from the category with the most posts to the category with the least.
How do I actually make the query string? 开发者_C百科I can't even think where to start.
SO... Is this the sort of thing that you are looking for?
SELECT category.name
, COUNT(*) as [Count]
FROM post
INNER JOIN postcategory ON post.id = postcategory.post_id
INNER JOIN category ON postcategory.category_id = category.id
ORDER BY count
GROUP BY category.name
精彩评论