我只想计算所有子评论以及所有属于画廊的图像中的所有喜欢。
SELECT Count(Message.id) AS subCount,
Count(likes.id),
Image.id,
Image.date_created,
Image.likes,
Image.path
FROM images AS Image
LEFT JOIN messages AS Message
ON ( Message.object_id = Image.id
AND Message.msg_type = 16 )
LEFT JOIN likes AS Likes
ON ( likes.object_id = Image.id
AND likes.object_type = 3 )
WHERE Image.gallery_id = 31
当我使用计数时,它只返回 1 行。有任何想法吗?