select * from table limit 0,10
上面句子中,0是起始offset,10是select出来的record数目,整句的意思是,选择table中前十条
当然也可以直接写成
select * from table limit 10
如果换个offset
select * from table limit 5,10
这句的意思是,返回第6至15行record,虽然语句中第一个参数写的是5,但是实际上,是从offset+1开始,也就是6,所以是第6行开始,包括第六行,总共10条,也就是去到第15条record
如果table数目特别多,需要跳转到后面第几十页的话,例如下面这个例子,每页20个,查看第501页
select * from table where id>=10000 order by id asc limit 0,20
前1页
select * from table where id < 10000 order by id asc limit 0,20
select * from table where id < 10000 order by id asc limit 20,20
后1页
select * from table where id >= 10000 order by id asc limit 20,20