php排序

关于order by排序:
单条件排序:order by id(按照id排序默认从小到大)
order by id desc(按照id排序从大到小)
多条件排序:order by date,id(先按照date从小到大再按照id从小到大)
order by date,id desc(先按照date从大到小再按照id从大到小)
order by date desc,id(先按照date从大到小再按照id从小到大)


ORDER BY 后可加2个字段,用英文逗号隔开。
f1用升序, f2降序,sql该这样写
ORDER BY f1, f2 DESC
也可以这样写,更清楚:
ORDER BY f1 ASC, f2 DESC
如果都用降序,必须用两个desc
ORDER BY f1 DESC, f2 DESC

原文地址:https://www.cnblogs.com/leonchen024/p/4269775.html