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

      <legend id='kiDQb'><style id='kiDQb'><dir id='kiDQb'><q id='kiDQb'></q></dir></style></legend>
    1. <small id='kiDQb'></small><noframes id='kiDQb'>

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

        带有 SET 变量语句的 Mysqli 查询(即多个查询)

        时间:2023-07-30
        • <legend id='jY3ur'><style id='jY3ur'><dir id='jY3ur'><q id='jY3ur'></q></dir></style></legend>
            <tbody id='jY3ur'></tbody>

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

          1. <small id='jY3ur'></small><noframes id='jY3ur'>

            • <bdo id='jY3ur'></bdo><ul id='jY3ur'></ul>
                1. <tfoot id='jY3ur'></tfoot>

                  本文介绍了带有 SET 变量语句的 Mysqli 查询(即多个查询)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想设置一个变量以在 mysqli 查询中使用.这不太行.在 mysqli 之前,我曾经设置查询调用.我玩 db->multi_query($sql) 没有运气.任何人都知道如何使这项工作包括 set 语句?

                  I want to set a variable to use in a mysqli query. This doesn't quite work. Prior to mysqli I used to set query calls. I played around with db->multi_query($sql) with no luck. Anyone out there have an idea how to make this work including a set statement?

                  $sql = 'SET @rownum := 0;';
                  $sql .= 'SELECT @rownum :=@rownum + 1 AS Rank, User_Id, COUNT(User_ID) AS Block_Count
                                 FROM Block_Owners;
                  
                  $stmt = $db->prepare($sql);
                  $stmt->bind_param('ii', $world, $userId);
                  // execute the query
                  $stmt->execute();
                  

                  推荐答案

                  在两个单独的查询中进行:

                  Do it in two separate queries:

                  $db->query('SET @rownum := 0');
                  $sql = 'SELECT @rownum :=@rownum + 1 AS Rank, User_Id, COUNT(User_ID) AS Block_Count FROM Block_Owners'
                  $stmt = $db->prepare($sql);
                  $stmt->bind_param('ii', $world, $userId);
                  $stmt->execute();
                  

                  但是请注意,您要运行的查询将始终返回单行(Rank = 1),因为您使用的是没有 GROUP BY 的聚合函数.

                  Note, however, that the query you want to run will always return a single row (with Rank = 1) since you are using an aggregate function without GROUP BY.

                  这篇关于带有 SET 变量语句的 Mysqli 查询(即多个查询)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 XAMPP 上启用 mysqli? 下一篇:致命错误:在非对象上调用成员函数 query()

                  相关文章

                  最新文章

                    <legend id='KMpLM'><style id='KMpLM'><dir id='KMpLM'><q id='KMpLM'></q></dir></style></legend>
                      <bdo id='KMpLM'></bdo><ul id='KMpLM'></ul>
                    <tfoot id='KMpLM'></tfoot>

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

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