什么情况下使用ORDER BY子句

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 01:02:47
什么情况下使用ORDER BY子句

什么情况下使用ORDER BY子句
什么情况下使用ORDER BY子句

什么情况下使用ORDER BY子句
数据排序的时候,排序一般是按照数据表的索引(比如主键,这个为默认排序),我们想根据时间排序如:
select * from table where 1 order by id desc(根据id倒序排列)
select * from table where 1 order by update_time desc,id desc(首先根据update_time倒序排列,如果update_time相同则根据id倒序排列)