排序查询
- 查询所有学生记录,按年龄升序排序
SELECT * FROM stu ORDER BY sage ASC;
或者 SELECT * FROM stu ORDER BY sage;
- 查询所有学生记录,按年龄降序排序
SELECT *FROM stu ORDER BY age DESC;
- 查询所有雇员,按月薪降序排序,如果月薪相同时,按编号升序排序
SELECT * FROM emp ORDER BY sal DESC,empno ASC;
- 查询所有学生记录,按年龄升序排序
SELECT * FROM stu ORDER BY sage ASC;
或者 SELECT * FROM stu ORDER BY sage;
- 查询所有学生记录,按年龄降序排序
SELECT *FROM stu ORDER BY age DESC;
- 查询所有雇员,按月薪降序排序,如果月薪相同时,按编号升序排序
SELECT * FROM emp ORDER BY sal DESC,empno ASC;
本文标题:MySQL 排序
本文链接:https://www.haomeiwen.com/subject/hokppqtx.html
网友评论