SELECT
p.product_id,
ifnull(
count(dp.post_id),
0
) as discussion_amount_posts
FROM
cscart_discussion
INNER JOIN cscart_products as p ON (
cscart_discussion.object_id = p.product_id
)
INNER JOIN cscart_discussion_posts as dp ON (
cscart_discussion.thread_id = dp.thread_id
AND cscart_discussion.object_type = 'P'
)
WHERE
dp.status = 'A'
and p.product_id in (152082)
GROUP BY
p.product_id