我有像
这样的查询SELECT COUNT( * ) As Publishid164 FROM `comments` WHERE `publishid` =164
它将获得Count of One publishid = 164
但是我希望传递更多像“
”这样的笨蛋SELECT COUNT( * ) Publishid FROM `comments` WHERE `publishid` IN (164,165)
但我想要不同的发布ID
我该怎么做
提前致谢
答案 0 :(得分:0)
如果您需要为每个publishid计数,则必须按
进行分组SELECT COUNT( * )
FROM comments
WHERE publishid IN (164,165)
GROUP BY publishid
如果您还需要publishid列
SELECT publishid, COUNT( * )
FROM comments
WHERE publishid IN (164,165)
GROUP BY publishid