select distinct c.id from Category c, Product p where (p.categoryId=c.id OR p.category2Id=c.id OR p.category3Id=c.id) AND p.active='yes'
0.001
SELECT Product.* FROM Product WHERE (Product.categoryId IN (11) OR Product.category2Id IN (11))AND Product.active = "yes" GROUP BY Product.id ORDER BY Product.sequence ASC LIMIT 0,20