1
我需要在Wordpress中運行一個查詢來獲取每月有多少帖子,包括零。每月WordPress的帖子數
我的查詢現在返回什麼,我試圖返回第一部分:
select
distinct date_format(post_date, '%y') "year",
date_format(post_date, '%b') "month",
from wp_posts
where post_type = 'post'
and post_status = 'publish'
group by date_format(post_date, '%y'), date_format(post_date, '%b')
order by date_format(post_date, '%y') desc, post_date
它返回類似:
| year | month | count |
------------------------------------
| 10 | Jan | 4 |
| 10 | Feb | 2 |
| 10 | Mar | 1 |
| 10 | Apr | 6 |
| 09 | Jan | 4 |
| 09 | Feb | 2 |
我需要返回類似:
| year | month | count |
------------------------------------
| 10 | Jan | 4 |
| 10 | Feb | 2 |
| 10 | Mar | 1 |
| 10 | Apr | 6 |
| 10 | May | 0 |
| 10 | Jun | 0 |
| 10 | Jul | 0 |
| 10 | Aug | 0 |
| 10 | Sep | 0 |
| 10 | Oct | 0 |
| 10 | Nov | 0 |
| 10 | Dec | 0 |
| 09 | Jan | 4 |
| 09 | Feb | 2 |
| 09 | Mar | 0 |
| 09 | Apr | 0 |
| 09 | May | 0 |
| 09 | Jun | 0 |
| 09 | Jul | 0 |
| 09 | Aug | 0 |
| 09 | Sep | 0 |
| 09 | Oct | 0 |
| 09 | Nov | 0 |
| 09 | Dec | 0 |
我會在Oracle中使用rownum,但我無法弄清楚使用MySQL語法的查詢。任何幫助是極大的讚賞。
幾乎相同的答案...你的是整潔,我會刪除我的:) +1 – 2010-07-20 00:10:33