我有下表:
-------------------------------------- PK integer date -------------------------------------- 1 0 2014/11/14 2 2 2014/11/01 3 0 2014/11/25 4 1 2014/11/01 5 0 2014/12/25 6 1 2014/12/01
我想要做的是按日期列排序,但也在整数列上按升序排序,并且将 11 月行放在 12 月行之前。所以我的输出应该是这样的:
-------------------------------------- PK integer date -------------------------------------- 1 0 2014/11/14 3 0 2014/11/25 4 1 2014/11/01 2 2 2014/11/01 5 0 2014/12/25 6 1 2014/12/01
最佳答案
试试这个:
ORDER BY YEAR(date), MONTH(date), integer, DAYOFMONTH(date)
关于php - MySQL 按日期和月内整数排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26834684/