mysql limit的使用方法

mysql的分页limit的使用方法大全
1.取表中的n行之后的m条元组(limit n,m)
select * from student limit 4,8; //取出student表中第4行后的8条元组(这里的区间是左开右闭)
2.取出表中前m行元素(limit m)
select * from student limit 3; //取出student表中的前3行元组
3.取出某表某页中的元素
在某表中满足某一条件的元组集合我们认为是页。
<1>取页中的n行之后的m条元组(limit n,m)
select * from student where score>75 limit 2,2; //取出满足成绩大于75分的页中2行以后两条元组
<2>取页中的m条元组(limit m)
select * from student where score>75 limit 2; //取出满足成绩大于75分的页中前2行元组

猜你喜欢

转载自www.cnblogs.com/FengZeng666/p/11387643.html