PHP MYSQL左联接3个表

PHP MYSQL左联接3个表,php,mysql,Php,Mysql,我有一个关于左加入MYSQL的问题 id_product // product table ---------- 1 2 3 id_comment | id_product // comment table ---------- ---------- 1 1 2 2 3 3 id_reply | id_comment | id_product // reply table -

我有一个关于左加入MYSQL的问题

id_product // product table
----------
    1
    2
    3

id_comment | id_product // comment table
----------   ----------
    1            1
    2            2
    3            3

id_reply | id_comment | id_product // reply table
--------   ----------   ----------
    1           1            1
    2           2            2
    3           3            3

"SELECT 
    `product.id_product`, `reply.id_comment`,
    `comment.id_comment`, 
    `COUNT(comment.id_comment) AS allcomment`,
    `COUNT(reply.id_reply) AS allreply`

FROM product

LEFT JOIN comment ON comment.id_product = product.id_product
LEFT JOIN reply ON reply.id_product = product.id_product AND reply.id_comment = comment.id_comment"

GROUP BY product.id_product"

$sumComment = $joinFetch['allcomment'] + $joinFetch['allreply']; // get total comments
输出比我预期的要多。实际上它必须是6。3+3=6

首先,它在只有一个左连接的情况下工作得非常好,但是当我添加另一个左连接时,它就是reply table。问题发生了


我的代码有什么问题?

也许您可以提供所需的输出。您能否具体说明您需要查看的确切输出?所以,它可以被解决!