【1】关于MySql limit offset 语法请参考以下测试示例SQL语句:
1 # limit后面显示1条数据,从索引为0行开始读取
2 SELECT *
3 FROM cfg_acct_free_res
4 WHERE product_id = '01086391522'
5 ORDER BY call_type DESC
6 LIMIT 1;
7 # 换句话说,LIMIT n 等价于 LIMIT 0, n
8
9 # limit后面显示1条数据,从索引为1行开始读取
10 SELECT *
11 FROM cfg_acct_free_res
12 WHERE product_id = '01086391522'
13 ORDER BY call_type DESC
14 LIMIT 1, 1;
15
16 # limit后面显示3条数据,从索引为1行开始读取
17 SELECT *
18 FROM cfg_acct_free_res
19 WHERE product_id = '01086391522'
20 ORDER BY call_type DESC
21 LIMIT 1, 3;
22
23 # limit后面显示3条数据,offset后面是从第1条开始读取
24 SELECT *
25 FROM cfg_acct_free_res
26 WHERE product_id = '01086391522'
27 ORDER BY call_type DESC
28 LIMIT 3 OFFSET 1;
29
30 # 换句话说,LIMIT语法与OFFSET的等价关系:从索引为1位置向后取3条记录
31 # 1.limit 1, 3
32 # 2.limit 3 offset 1 等价于limit 1, 3
Good Good Study, Day Day Up.
顺序 选择 循环 总结