select * from table limit 5; --返回前5行
select * from table limit 0,5; --返回前5行
select * from table limit 5,10; --返回6-15行
当一个查询语句偏移量offset
很大的时候,如select * from table limit 10000,10
,最好不要直接使用limit
,而是先获取到offset
的id
后,再直接使用limit size
来获取数据,效果会好很多。
select
*
from
customers
where
customer_id >= (select customer_id from customers order by customer_id limit 10000,1)
limit
10;