1. <tfoot id='63X47'></tfoot>

    1. <i id='63X47'><tr id='63X47'><dt id='63X47'><q id='63X47'><span id='63X47'><b id='63X47'><form id='63X47'><ins id='63X47'></ins><ul id='63X47'></ul><sub id='63X47'></sub></form><legend id='63X47'></legend><bdo id='63X47'><pre id='63X47'><center id='63X47'></center></pre></bdo></b><th id='63X47'></th></span></q></dt></tr></i><div id='63X47'><tfoot id='63X47'></tfoot><dl id='63X47'><fieldset id='63X47'></fieldset></dl></div>
      • <bdo id='63X47'></bdo><ul id='63X47'></ul>

      <legend id='63X47'><style id='63X47'><dir id='63X47'><q id='63X47'></q></dir></style></legend>

      <small id='63X47'></small><noframes id='63X47'>

      MySQL 数据 - 实现分页的最佳方式?

      时间:2023-08-19
      <i id='WfA6s'><tr id='WfA6s'><dt id='WfA6s'><q id='WfA6s'><span id='WfA6s'><b id='WfA6s'><form id='WfA6s'><ins id='WfA6s'></ins><ul id='WfA6s'></ul><sub id='WfA6s'></sub></form><legend id='WfA6s'></legend><bdo id='WfA6s'><pre id='WfA6s'><center id='WfA6s'></center></pre></bdo></b><th id='WfA6s'></th></span></q></dt></tr></i><div id='WfA6s'><tfoot id='WfA6s'></tfoot><dl id='WfA6s'><fieldset id='WfA6s'></fieldset></dl></div>

            <tfoot id='WfA6s'></tfoot>
          • <small id='WfA6s'></small><noframes id='WfA6s'>

              <tbody id='WfA6s'></tbody>
            • <legend id='WfA6s'><style id='WfA6s'><dir id='WfA6s'><q id='WfA6s'></q></dir></style></legend>
              • <bdo id='WfA6s'></bdo><ul id='WfA6s'></ul>
                本文介绍了MySQL 数据 - 实现分页的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我的 iPhone 应用程序连接到我的 PHP Web 服务以从 MySQL 数据库中检索数据.一个请求可以返回 500 个结果.

                My iPhone app connects to my PHP web service to retrieve data from a MySQL database. A request can return 500 results.

                实现分页和一次检索 20 个项目的最佳方法是什么?

                What is the best way to implement paging and retrieve 20 items at a time?

                假设我收到了数据库中的前 20 个广告.现在我该如何请求接下来的 20 个广告?

                Let's say I receive the first 20 ads from my database. Now how can I request for the next 20 ads?

                推荐答案

                来自 MySQL 文档:

                LIMIT 子句可用于限制 SELECT 语句返回的行数.LIMIT 接受一个或两个数字参数,它们都必须是非负整数常量(除非使用准备好的语句).

                The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).

                有两个参数,第一个参数指定要返回的第一行的偏移量,第二个参数指定要返回的最大行数.初始行的偏移量为 0(不是 1):

                With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):

                SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15
                

                要检索从某个偏移量到结果集末尾的所有行,您可以为第二个参数使用一些大数字.此语句检索从第 96 行到最后一行的所有行:

                To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

                SELECT * FROM tbl LIMIT 95,18446744073709551615;
                

                带一个参数,该值指定从结果集的开头返回的行数:

                With one argument, the value specifies the number of rows to return from the beginning of the result set:

                SELECT * FROM tbl LIMIT 5;     # Retrieve first 5 rows
                

                换句话说,LIMIT row_count 等价于 LIMIT 0, row_count.

                In other words, LIMIT row_count is equivalent to LIMIT 0, row_count.

                这篇关于MySQL 数据 - 实现分页的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:SQL 语句忽略了 where 参数 下一篇:内爆一个在 python MySQLDB IN 子句中使用的列表

                相关文章

                最新文章

                <i id='brnEp'><tr id='brnEp'><dt id='brnEp'><q id='brnEp'><span id='brnEp'><b id='brnEp'><form id='brnEp'><ins id='brnEp'></ins><ul id='brnEp'></ul><sub id='brnEp'></sub></form><legend id='brnEp'></legend><bdo id='brnEp'><pre id='brnEp'><center id='brnEp'></center></pre></bdo></b><th id='brnEp'></th></span></q></dt></tr></i><div id='brnEp'><tfoot id='brnEp'></tfoot><dl id='brnEp'><fieldset id='brnEp'></fieldset></dl></div>

                  <legend id='brnEp'><style id='brnEp'><dir id='brnEp'><q id='brnEp'></q></dir></style></legend>
                    <bdo id='brnEp'></bdo><ul id='brnEp'></ul>
                1. <small id='brnEp'></small><noframes id='brnEp'>

                  <tfoot id='brnEp'></tfoot>