SELECT
DISTINCT pc.category_id,
count(DISTINCT pc.product_id) as total_products
FROM
cscart_products AS products
LEFT JOIN cscart_products_categories AS pc ON products.product_id = pc.product_id
WHERE
1
AND products.product_id IN (
7574, 6855, 8238, 20396, 10468, 7673,
9496, 13033, 7181, 9780, 9796, 9794,
10805, 9529, 18159, 9351, 6964, 10156,
10549, 11010, 11014, 11013, 11018,
6894, 6896, 12818, 12750, 20303, 20304,
20305, 19788, 20306, 20776, 20781,
20782, 20032, 19951, 23067, 23066,
18458, 18452, 18713, 13467, 22527,
23339, 21130, 9804, 21081, 9296, 19924,
6939, 8346, 21555, 21556, 21557, 21559,
21561, 21563, 21564, 21558, 21560,
21562, 13416, 6863, 7646, 18834, 18836,
13699, 13692, 20147, 18797, 6664, 7003,
7004, 7006, 7007, 7010, 7075, 7540,
7963, 8023, 8037, 8093, 8099, 8101,
8110, 8140, 8144, 8148, 8151, 8157,
8192, 8204, 8205, 8231, 9806, 10140,
10201, 10286, 10413, 10685, 11634,
11638, 12598, 12857
)
GROUP BY
pc.category_id