MYSQL的降序排列

MYSQL的降序排列

MYSQL的降序排列

今天查询时需要用到降序排列,老是出错,仔细检查SQL语法也没问题,

后来才知道,原来order by要放在limit的前面。或者说limit要放在最后。

[sql]

String sql = "select * from s_dayreport " +

"where userId = "+userId+" " +

"order by taskDate desc " +

"limit "+firstResult+","+maxResults+" ";