在这里选择查询enter image description here
select rac_username, rac_profilepicture, tafd_postid, tafd_postcontent, tafd_postimage_source, DATE_FORMAT(tafd_postadded,'%M %d, %Y') tafd_postadded,tafd_imotion, (select count(rpg_actormakeget) from r_post_getyou where rpg_postrelate = tafd_postid and rpg_isremoved = 0) as tafd_igetyoucount, (select count(rpg_postrelate) from r_post_getyou where rpg_postrelate = tafd_postid and rpg_actormakeget = (select rac_accountid from r_account_credentials where rac_username = 'zheuswalker' )) as isliked, (select count(rfc_commentid) from r_feeds_comments where rfc_feedparent = tafd_postid) rfc_commentcount from t_account_feeds inner join r_account_credentials on r_account_credentials.rac_accountid = t_account_feeds.tafd_postcreator
ORDER BY STR_TO_DATE (tafd_postadded,'%M %d, %Y') ASC
我已经尝试过按desc排序日期,但仍然没有得到预期的结果。我希望日期按升序排列(从最新到最早)。
我也尝试通过此命令(ORDER BY tafd_postadded asc)和see picture对其进行订购,请注意,2019年3月在2018年6月至2018年11月之间
答案 0 :(得分:0)
STR_TO_DATE比较字符串,因此正常的情况是,火星在11月之前,因为字母M在字母N之前。
您应该这样做:
ORDER BY tafd_postadded DESC
从最新到最旧的描述
从最早到最新的升序
答案 1 :(得分:0)
我在tafd_postadded列上使用了 datetime ,因此在对日期时间进行排序时,我们应该使用UNIX_TIMESTAMP();
select * from table order by UNIX_TIMESTAMP(datetime column) desc