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

      <legend id='Qhx5Q'><style id='Qhx5Q'><dir id='Qhx5Q'><q id='Qhx5Q'></q></dir></style></legend>
        <bdo id='Qhx5Q'></bdo><ul id='Qhx5Q'></ul>
      <i id='Qhx5Q'><tr id='Qhx5Q'><dt id='Qhx5Q'><q id='Qhx5Q'><span id='Qhx5Q'><b id='Qhx5Q'><form id='Qhx5Q'><ins id='Qhx5Q'></ins><ul id='Qhx5Q'></ul><sub id='Qhx5Q'></sub></form><legend id='Qhx5Q'></legend><bdo id='Qhx5Q'><pre id='Qhx5Q'><center id='Qhx5Q'></center></pre></bdo></b><th id='Qhx5Q'></th></span></q></dt></tr></i><div id='Qhx5Q'><tfoot id='Qhx5Q'></tfoot><dl id='Qhx5Q'><fieldset id='Qhx5Q'></fieldset></dl></div>
      1. 如何在MYSQL中的单个查询中计算和限制记录?

        时间:2023-07-15

          <small id='vsKLN'></small><noframes id='vsKLN'>

          <legend id='vsKLN'><style id='vsKLN'><dir id='vsKLN'><q id='vsKLN'></q></dir></style></legend>

              <bdo id='vsKLN'></bdo><ul id='vsKLN'></ul>

              1. <tfoot id='vsKLN'></tfoot>
                  <tbody id='vsKLN'></tbody>

                  <i id='vsKLN'><tr id='vsKLN'><dt id='vsKLN'><q id='vsKLN'><span id='vsKLN'><b id='vsKLN'><form id='vsKLN'><ins id='vsKLN'></ins><ul id='vsKLN'></ul><sub id='vsKLN'></sub></form><legend id='vsKLN'></legend><bdo id='vsKLN'><pre id='vsKLN'><center id='vsKLN'></center></pre></bdo></b><th id='vsKLN'></th></span></q></dt></tr></i><div id='vsKLN'><tfoot id='vsKLN'></tfoot><dl id='vsKLN'><fieldset id='vsKLN'></fieldset></dl></div>
                1. 本文介绍了如何在MYSQL中的单个查询中计算和限制记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在按如下方式搜索表中的记录:

                  SELECT Id, Name FROM my_table WHERE Name LIKE '%prashant%' LIMIT 0, 10;

                  现在,我添加了 LIMIT 来维护我的分页.但是当用户搜索单词prashant"时,我拥有的prashant"总记录数为 124.但是由于应用于查询的限制,所以它只在我的 PHP 脚本中获取 10 条记录,当我计算 PHP 代码中的 mysql 变量时,它返回找到的总记录数为 10.

                  所以基本上我想使用单个查询进行计数和限制,通过对上述查询进行一些修改,我想要记录的总数(124).我不想运行单独的 count(*) 查询来计算查询找到的总结果.

                  谢谢.

                  解决方案

                  SELECT SQL_CALC_FOUND_ROWS身份证、姓名从 my_table在哪里名称 LIKE '%prashant%'限制 0, 10;# 查找总行数选择 FOUND_ROWS();

                  更多信息

                  I am searching for records in a table as follows:

                  SELECT Id, Name FROM my_table WHERE Name LIKE '%prashant%' LIMIT 0, 10;
                  

                  Now, I am adding LIMIT to maintain my paging. But when user searches for word 'prashant' then total records I have is 124 for 'prashant'. But as the limit applied to the query so it only fetches 10 records in my PHP script and when I am count the mysql variable in PHP code it returns total records found is 10.

                  So basically I want to count and Limit using a single query, by making some modification in the above query, I want the total count (124) of records. I don't want to run a separate count(*) query for just counting the total result found by the query.

                  Thanks.

                  解决方案

                  SELECT SQL_CALC_FOUND_ROWS
                    Id, Name
                  FROM my_table
                  WHERE
                    Name LIKE '%prashant%'
                  LIMIT 0, 10;
                  
                  # Find total rows
                  SELECT FOUND_ROWS();
                  

                  more info

                  这篇关于如何在MYSQL中的单个查询中计算和限制记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用 PHP 获取 CSV 文件中的总行数? 下一篇:在 PHP 中通过对多维数组进行分组来计数

                  相关文章

                  <small id='n8FUp'></small><noframes id='n8FUp'>

                2. <i id='n8FUp'><tr id='n8FUp'><dt id='n8FUp'><q id='n8FUp'><span id='n8FUp'><b id='n8FUp'><form id='n8FUp'><ins id='n8FUp'></ins><ul id='n8FUp'></ul><sub id='n8FUp'></sub></form><legend id='n8FUp'></legend><bdo id='n8FUp'><pre id='n8FUp'><center id='n8FUp'></center></pre></bdo></b><th id='n8FUp'></th></span></q></dt></tr></i><div id='n8FUp'><tfoot id='n8FUp'></tfoot><dl id='n8FUp'><fieldset id='n8FUp'></fieldset></dl></div>
                3. <legend id='n8FUp'><style id='n8FUp'><dir id='n8FUp'><q id='n8FUp'></q></dir></style></legend>
                    <bdo id='n8FUp'></bdo><ul id='n8FUp'></ul>

                    <tfoot id='n8FUp'></tfoot>