Mysql第六篇【排序及分页】

排序

`select * from demo1 order by 字段 asc,字段 desc;

说明:

asc 升序,desc 降序

默认是asc

limit分页

select * from demo2 limit 偏移量,几行数据

说明:

offset:表示偏移量,通俗点讲就是跳过多少行,offset可以省略,默认为0,表示跳过0行;范围:[0,+∞)。

count:跳过offset行之后开始取数据,取count行记录;范围:[0,+∞)。

limit中offset和count的值不能用表达式。

猜你喜欢

转载自www.cnblogs.com/kwdlh/p/12726632.html