作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我按月份和年份列出所有新闻文章,以及该月发生的文章数量...
但是我注意到在新的一年里它只按月排序而不是
这是我的 SQL
$archive1_sql = "SELECT YEAR(`ndate`) AS 'year', MONTH(`ndate`) AS 'month', COUNT(`nid`) AS 'count' FROM `weaponsnews` GROUP BY YEAR(`ndate`), MONTH(`ndate`) DESC";
它返回
December 2012 (1)
November 2012 (11)
October 2012 (6)
September 2012 (8)
August 2012 (16)
July 2012 (8)
June 2012 (6)
May 2012 (12)
April 2012 (4)
March 2012 (2)
February 2012 (4)
January 2013 (1)
我想要它做的是这样的
January 2013 (1)
December 2012 (1)
November 2012 (11)
October 2012 (6)
September 2012 (8)
August 2012 (16)
July 2012 (8)
June 2012 (6)
May 2012 (12)
April 2012 (4)
March 2012 (2)
February 2012 (4)
我该怎么做?
最佳答案
也添加带有 YEAR 的 DESC
SELECT
YEAR(`ndate`) AS 'year',
MONTH(`ndate`) AS 'month',
COUNT(`nid`) AS 'count'
FROM `weaponsnews`
GROUP BY YEAR(`ndate`) , MONTH(`ndate`)
ORDER BY YEAR(`ndate`) DESC , MONTH(`ndate`) DESC
关于php - MYSQL 返回日期乱序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14528770/
我是一名优秀的程序员,十分优秀!