我正在尝试获取两个表的计数值并使用成员 ID 作为键来计算其他表的行数,到目前为止我有这段代码,但它为 comCount 输出一个大值,为 chatCount 输出空值。这是我的代码
SELECT members.*
, comments.commenter_id
, cb.user_id
, COUNT(comments.comment) AS comCount
, COUNT(cb.message) AS chatCount
FROM members
INNER JOIN comments ON members.id = comments.commenter_id
INNER JOIN chat_box AS cb ON members.id = cb.user_id
WHERE members.id ='$profileId'`