Alexking在Simple SQL Queries for Blog Stats中给出了关于wordpress博客数据统计的SQL查询命令。
查询2006年所有的文章的SQL命令:
SELECT COUNT(*)
FROM `wp_posts`
WHERE post_date >= ‘2006-01-01′
AND post_date < ‘2007-01-01’
AND post_status = ‘publish’
查询2006年所有评论的SQL命令:
SELECT COUNT(*)
FROM `wp_comments`
WHERE comment_date >= ‘2006-01-01′
AND comment_date < ‘2007-01-01’
AND comment_approved = ‘1′
查询2006每篇文章平均字数的SQL命令:
SELECT AVG(LENGTH(post_content))
FROM `wp_posts`
WHERE post_date >= ‘2006-01-01′
AND post_date < ‘2007-01-01’
AND post_status = ‘publish’
查询2006年文章总字数的SQL命令:
SELECT SUM(LENGTH(post_content))
FROM `wp_posts`
WHERE post_date >= ‘2006-01-01′
AND post_date < ‘2007-01-01’
AND post_status = ‘publish’
转载请注明:夜阑小雨 » 查询wordpress博客资料的SQL命令