View Single Post
  #2 (permalink)  
Old 05-19-2006, 06:06 AM
ben ben is offline
Administrator
 
Join Date: Mar 2007
Posts: 92
ben has disabled reputation
Default MySQL answer. Re: Find Your Most-Commented Blog Categories in Wordpress?

This question was posted on [a href="http://www.openwin.org/mike/index.php/archives/2006/05/find-your-most-commented-blog-categories/trackback/"]Mike Hillyer's blog[/a], which he kindly allowed to be posted here.

[sql]
SELECT wp_categories.cat_name, COUNT(wp_comments.comment_id)
FROM wp_categories
LEFT JOIN wp_post2cat ON wp_categories.cat_id = wp_post2cat.category_id
LEFT JOIN wp_comments ON wp_post2cat.post_id = wp_comments.comment_post_id
WHERE comment_approved != ’spam’
GROUP BY wp_categories.cat_id
ORDER BY 2 DESC
[/sql]

+------------------------------------------+-------------------------------+
| cat_name | COUNT(wp_comments.comment_id) |
+------------------------------------------+-------------------------------+
| MySQL | 307 |
| Visual Basic 6 | 236 |
| General | 119 |
| Open Source | 43 |
| Rants | 42 |
| Crystal Reports | 40 |
| News | 39 |
| Gadgets | 26 |
| Windows | 24 |
| PHP | 21 |
| 2006 MySQL User's Conference & Expo | 13 |
| VB.NET | 12 |
| 2004 MySQL User's Conference & Expo | 10 |
| Reviews | 7 |
| 2005 MySQL User's Conference & Expo | 6 |
| Photography | 5 |
| MySQL Tip of the Week | 4 |
| Hardware | 3 |
| Money | 2 |
+------------------------------------------+-------------------------------+
19 rows in set (0.16 sec)
Reply With Quote