• <small id='lLhsG'></small><noframes id='lLhsG'>

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

    1. <legend id='lLhsG'><style id='lLhsG'><dir id='lLhsG'><q id='lLhsG'></q></dir></style></legend>

        <bdo id='lLhsG'></bdo><ul id='lLhsG'></ul>
      1. <tfoot id='lLhsG'></tfoot>

        从一个表中选择,从另一个 id 链接的表中计数

        时间:2023-10-09

          • <bdo id='fb7e1'></bdo><ul id='fb7e1'></ul>

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

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

                  <tfoot id='fb7e1'></tfoot>

                • <legend id='fb7e1'><style id='fb7e1'><dir id='fb7e1'><q id='fb7e1'></q></dir></style></legend>
                  本文介绍了从一个表中选择,从另一个 id 链接的表中计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是我的代码:

                  $sql = mysql_query("select c.name, c.address, c.postcode, c.dob, c.mobile, c.email, 
                                      count(select * from bookings where b.id_customer = c.id) as purchased, count(select * from bookings where b.the_date > $now) as remaining, 
                                      from customers as c, bookings as b 
                                      where b.id_customer = c.id
                                      order by c.name asc");
                  

                  您可以看到我正在尝试做什么,但我不确定如何正确编写此查询.

                  you can see what i am trying to do, but im not sure how to write this query properly.

                  这是我得到的错误:

                  警告:mysql_fetch_assoc():已提供参数不是有效的 MySQL 结果资源

                  Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

                  这是我的 mysql_fetch_assoc:

                  heres my mysql_fetch_assoc:

                  <?php
                  
                  while ($row = mysql_fetch_assoc($sql))
                  {
                      ?>
                  
                      <tr>
                      <td><?php echo $row['name']; ?></td>
                      <td><?php echo $row['mobile']; ?></td>
                      <td><?php echo $row['email']; ?></td>
                      <td><?php echo $row['purchased']; ?></td>
                      <td><?php echo $row['remaining']; ?></td>
                      </tr>
                  
                      <?php   
                  }
                  
                  ?>
                  

                  推荐答案

                  尝试改变...

                  count(select * from bookings where b.id_customer = c.id)
                  

                  ...到...

                  (select count(*) from bookings where b.id_customer = c.id)
                  

                  这篇关于从一个表中选择,从另一个 id 链接的表中计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:仅加入“最新"用t-sql记录 下一篇:是否有关于使用显式 ANSI JOIN 与隐式连接的 Oracle 官方建议?

                  相关文章

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

                  <tfoot id='PPPzU'></tfoot>
                    • <bdo id='PPPzU'></bdo><ul id='PPPzU'></ul>
                  1. <small id='PPPzU'></small><noframes id='PPPzU'>