一、ORDER BY关键字用法
ORDER BY关键字用于对数据进行排序,默认ASC(升序),可以DESC关键字变为降序。
ORDER BY关键字语法:
SELECT * from 表名 WHERE 条件语句 ORDER BY 列名1,列名2... ASC\DESC;
演示student表:
查询name = ‘小明’的数据,并按class_id降序排列,例:
SELECT * from student WHERE name = '小明' ORDER BY class_id DESC;
运行结果: