limit用法

limit是mysql的语法select * from table limit m,n

其中m是指记录开始的index,从0开始,表示第一条是指从第m+1条开始,取n条。

 select * from tablename limit 2,4即取出第3条至第6条,4条记录

mysql求前几条数据之和:

select sum(stats_unique_unique)
from
(SELECT stats_unique_unique from t_stats where fk_site = 9 limit 0, 7) a; 
select * from table limit 5; --返回前5行

select * from table limit 0,5; --同上,返回前5行

select * from table limit 5,10; --返回6-15行

猜你喜欢

转载自www.cnblogs.com/slhs/p/9709276.html