【问题标题】:Group by column name -> specific value in that column按列名分组 -> 该列中的特定值
【发布时间】:2015-02-10 13:44:55
【问题描述】:

我被这个查询卡住了...

SELECT SUM(points) AS total FROM `library` AS lib JOIN subitem_lib AS subitem on lib.id = subitem.lid JOIN items AS item on subitem.iid = item.id group by item.pid

是否可以从 item.pid 中获取特定的字段值? 此列可以有不同的值 (1 -> 9999999...)

我用 php 渲染了这个页面,它给了我一个项目 id (pid)。现在,我的计数应该得到该项目的特定分数。

非常感谢任何帮助。

【问题讨论】:

  • WHERE item.pid = yourpidvaluehere?
  • 添加where item.pid = XXX ?
  • 确实是的..这是一个愚蠢的问题。感谢您的帮助

标签: php sql group-by sum


【解决方案1】:

您需要在查询中添加 where 条件以将结果限制为特定的

【讨论】:

    猜你喜欢
    • 2014-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多