gpt4 book ai didi

mysql - 统计某个类别和月份/年份的已发布帖子数量

转载 作者:行者123 更新时间:2023-11-29 14:48:00 25 4
gpt4 key购买 nike

我想统计某个类别和月份/年份的已发布帖子,但我不能...

我可以为一个类别(没有设定的月份/年份)做:

SELECT wp_term_taxonomy.count
FROM wp_terms, wp_term_taxonomy
WHERE wp_terms.term_id=wp_term_taxonomy.term_id
AND wp_term_taxonomy.term_id=7

但不包括月份/年份:

SELECT count
FROM wp_term_taxonomy, wp_posts, wp_term_relationships
WHERE wp_posts.ID = wp_term_relationships.object_id
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND wp_term_taxonomy.term_id = '7'
AND wp_posts.post_type = 'post'
AND wp_posts.post_status = 'publish'
AND wp_posts.post_date LIKE '2011-06-%'

感谢您的帮助:)

最佳答案

SELECT COUNT(*)
FROM wp_term_taxonomy, wp_posts, wp_term_relationships
WHERE wp_posts.ID = wp_term_relationships.object_id
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND wp_term_taxonomy.term_id = '7'
AND wp_posts.post_type = 'post'
AND wp_posts.post_status = 'publish'

AND YEAR(wp_posts.post_date) =2011
AND MONTH(wp_posts.post_date) =6

或者用 Between 替换最后两行

AND wp_posts.post_date BETWEEN '2011-06-01' AND '2011-06-30'

关于mysql - 统计某个类别和月份/年份的已发布帖子数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6466002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com