什么情况下使用ORDER BY子句

学习 时间:2026-04-01 12:15:03 阅读:4240
什么情况下使用ORDER BY子句

最佳回答

拉长的鸵鸟

故意的灯泡

2026-04-01 12:15:03

数据排序的时候,排序一般是按照数据表的索引(比如主键,这个为默认排序),我们想根据时间排序如: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倒序排列)

最新回答共有2条回答

  • 傲娇的芝麻
    回复
    2026-04-01 12:15:03

    数据排序的时候,排序一般是按照数据表的索引(比如主键,这个为默认排序),我们想根据时间排序如: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倒序排列)

上一篇 体现出我们对什么事物感兴趣的词语是什么?

下一篇 A:Could you tell me if ---- tomrrow B:Sorry,I' ve no idea.