我有一个包含月份和年份字段的mysql表,如下所示.
year month filename filepath
2013 Feb 2013Feb_Report.xlsx ./main_reports/2013Feb_Report.xlsx
2013 Jan 2013Jan_Report.xlsx ./main_reports/2013Jan_Report.xlsx
2012 Jul 2012Jul_Report.xlsx ./main_reports/2012Jul_Report.xlsx
2013 Mar 2013Mar_Report.xlsx ./main_reports/2013Mar_Report.xlsx
2011 Mar monthly report180413.xlsx ./main_reports/monthly report180413.xlsx
2012 Sep 2012Sep_Report.xlsx ./main_reports/2012Sep_Report.xlsx
2012 Oct 2012Oct_Report.xlsx ./main_reports/2012Oct_Report.xlsx
Run Code Online (Sandbox Code Playgroud)
我正在检索此表中的所有字段并将其打印如下.
2011 Mar : monthly report180413.xlsx
2012 Sep : 2012Sep_Report.xlsx
2012 Oct : 2012Oct_Report.xlsx
2013 Jan : 2013Jan_Report.xlsx
Run Code Online (Sandbox Code Playgroud)
我想通过按DESC顺序对月份和年份字段进行排序来检索此表,如下所示.我怎样才能做到这一点?我应该更改月份和年份字段的数据类型吗?请帮忙..
2013 Jan : 2013Jan_Report.xlsx
2012 Oct : 2012Oct_Report.xlsx
2012 Sep : 2012Sep_Report.xlsx
2011 Mar : monthly report180413.xlsx
Run Code Online (Sandbox Code Playgroud)
我使用的sql查询如下.它以DESC顺序检索年份和月份,但月份按DESC顺序排列,即'Jan'高于'Feb'.我需要的是'Jan'上面的'Feb'..
"SELECT * FROM main_reports ORDER BY year DESC, …
Run Code Online (Sandbox Code Playgroud)