mysql分页和排序
排序(order by):
- 升序 ASC
- 降序 DESC
SELECT 字段 FROM 表 JOIN 表 ON 条件 WHERE 条件 ORDER BY 字段 DESC/ASC
SELECT student.`StudentNo`,`StudentName`,`SubjectName`,`StudentResult` FROM `student`
RIGHT JOIN`result` ON student.`StudentNo`=result.`StudentNo`
INNER JOIN `subject` ON result.`SubjectNo`=subject.`SubjectNo`
WHERE `SubjectName`='线性代数'
ORDER BY `StudentResult` DESC
分页(limit):缓解数据库压力,增加观赏性 瀑布流:无限往下刷
语法:limit 起始位置(第几条数据,从0开始) 页面大小
SELECT student.`StudentNo`,`StudentName`,`SubjectName`,`StudentResult` FROM `student`
RIGHT JOIN`result` ON student.`StudentNo`=result.`StudentNo`
INNER JOIN `subject` ON result.`SubjectNo`=subject.`SubjectNo`
WHERE `SubjectName`='线性代数'
ORDER BY `StudentResult` DESC
LIMIT 1,1
网页应用:
LIMIT (第N页-1)*pageSize,pageSize