SELECT a.object_id, COUNT(b.post_id) as total_items FROM cscart_discussion as a LEFT JOIN cscart_discussion_posts as b ON a.thread_id = b.thread_id WHERE a.object_type = 'M' AND b.status = 'A' GROUP BY a.object_id
{ "query_block": { "select_id": 1, "message": "no matching row in const table" } }