我有这个输入。
October 21 , 2010
October 14 , 2007
October 08 , 2010
March 19 , 2009
June 25 , 2009
June 21 , 2013
June 21 , 2013
June 19 , 2006
June 01 , 2009
July 26 , 2013
July 25 , 2012
July 23 , 2013
July 19 , 2013
July 01 , 2009
January 31 , 2013
January 23 , 2013
January 23 , 2011
January 19 , 2013
January 01 , 2000
February 17 , 2011
February 16 , 1998
December 25 , 2003
August 31 , 2013
August 04 , 2013
August 03 , 2013
August 03 , 2013
August 03 , 2013
April 26 , 2013
April 26 , 2013
April 19 , 2005
我想订购这个,以便最新的日期在最前面..但我似乎无法做到,有人可以提供解决方案吗?
这是我的sql:
$sql = "SELECT * FROM $tbl_name WHERE Length(Year) > 7 AND `Title`
LIKE '%" . $q . "%' AND `Genres` LIKE '%" . $genre . "%' AND `Actors`
LIKE '%" . $actor . "%' AND `Year` <> 'Unknown'
ORDER BY `Year` DESC LIMIT $start, $limit";
答案 0 :(得分:1)
所以,这是2列,对吗?
然后这样做:
SELECT
STR_TO_DATE(CONCAT(month_day_column, ', ', year_column), '%M %d, %Y') AS your_ISO_conform_date
FROM yourTable
ORDER BY your_ISO_conform_date DESC
答案 1 :(得分:1)
我没有在工作中使用MySQL,主要是SQL Server,我在一秒内发现了这个链接:https://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_str-to-date
select str_to_date('October 21 , 2010', '%M %d,%Y')