【发布时间】:2018-08-07 02:15:35
【问题描述】:
所以我有这个查询:
SELECT Posts.[Post ID], Count(Comments.[Comment ID]) AS [CountOfComment ID],
Count(Shares.[Share ID]) AS [CountOfShare ID],
Count(Likes.[Like ID]) AS [CountOfLike ID]
FROM ((Posts INNER JOIN Likes ON Posts.[Post ID] = Likes.[Post ID])
INNER JOIN Shares ON Posts.[Post ID] = Shares.[Post ID])
INNER JOIN Comments ON Posts.[Post ID] = Comments.[Post ID]
WHERE posts.[post id] = 5
GROUP BY Posts.[Post ID];
应该返回结果:
post.[post id]= 5
CountofcommentID= 4
CountofShareID = 5
CountofLikeID = 15
但我得到的是post.[post id] = 5, and the rest =300.
我知道这是因为它正在计算所有 ID 的所有排列,但是我如何更改它以获得我想要的结果?
【问题讨论】:
-
ms访问还是mysql????
-
语法明显是MS Access,所以我调整了标签。
标签: sql database ms-access count