select (
select count(cp.product_id)
from product as cp
where cp.color_id = :cid
and cp.pr_id = :pid
and cp.manuf_id = :mid
and cp.comp = p.comp
) as total,
p.comp,
IF(p.comp = 1, 'Совместимый', 'Оригинальный') as name
from product p
group by p.comp;