Mysql-limit用法

Mysql-limit用法

语法:
SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset
LIMIT 接受一个或两个数字参数。参数必须是一个整数常量。

如果给定两个参数,第一个参数指定第一个返回记录行的偏移量,第二个参数指定返回记录行的最大数目。

1
2
3
4
5
6
7
8
9
//取前15条记录:
select * from tablename limit 15;
select * from tablename order by orderfield desc/asc limit 0,15;

// 检索记录行 6-15 ,注意,10为偏移量
mysql> SELECT * FROM table LIMIT 5,10;

// 检索记录行 96-last
mysql> SELECT * FROM table LIMIT 95,-1;