• <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 链接的表中计数

        select from one table, count from another where id#39;s linked(从一个表中选择,从另一个 id 链接的表中计数)

          • <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 链接的表中计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Building a comma separated list?(建立一个逗号分隔的列表?)
                  Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                  How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                  Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                  Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                  SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)

                    <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>

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