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 (
23414, 23415, 23416, 23417, 23418, 23419,
23420, 23421, 23422, 23423, 23424,
23425, 23426, 23427, 23428, 23429,
23430, 23431, 23432, 23433, 23434,
23435, 23436, 23437, 23438, 23439,
23440, 23441, 23442, 23443, 23444,
23445, 23446, 23447, 23448, 23449,
23450, 23451, 23452, 23453, 23454,
23455, 23456, 23457, 23458, 23459,
23460, 23461, 23462, 23463, 23464,
23465, 23466, 23467, 23468, 23469,
23470, 23471, 23472, 23473, 23474,
23475, 23476, 23477, 23478, 23479,
23480, 23481, 23482, 23483, 23484,
23485, 23486, 23487, 23488, 23489,
23490, 23491, 23492, 23493, 23494,
23495, 23496, 23497, 23498, 23499,
23564, 23569, 23570, 23571, 23572,
23890, 23928, 23929, 23930, 23931
)
GROUP BY
pc.category_id