早上修改代码,增长排序功能,因而我就在以前sql的最后面增长了order by。发现sql出错:sql
SELECT item_id,title,price,pic,last_modify_time,detail,sellor,sellor_addr FROM item WHERE isnew=0 LIMIT 10 OFFSET 0 ORDER BY id DESC
试验发现当Limit子句和Order子句同时存在时候,Order子句必需要在前面,逻辑上也很好理解,排序完成后,再进行截取所须要的部分。code
SELECT item_id,title,price,pic,last_modify_time,detail,sellor,sellor_addr FROM item WHERE isnew=0 ORDER BY id DESC LIMIT 10 OFFSET 0