将字段依次写在order by 后面即可 , 中间用逗号隔开 select * from 表 order by time , name select * from 表 order by time asc , name asc select * from 表 order by time desc , name desc select * from 表 order by time asc , name desc select * from 表 order by time desc , name asc (注: asc 表示升序 , desc表示降序 , 未明确写明排序方式时默认是升序 ) 与之类似的语法是 group by , 按多个字段分组时 , 也是依次将多个字段写在group by 的后面 , 并用逗号隔开 , 范例如下: select time , name , sum(*) from 表 group by time , name
先按时间排序,再按姓名排序 sql语句
最新推荐文章于 2025-01-06 16:12:31 发布