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

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

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

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