SELECT DISTINCT c.categoryID FROM SC_products p LEFT JOIN SC_category_product c ON p.productID=c.productID WHERE p.categoryID<>1 and enabled=1 AND ( p.brandID=47 ) AND ( (p.productID IN (51683,51684,51685,51686,41978,46588,31627,45736,38592,38593,42900,38595,39722,44396)) OR (categoryID IN (3502,3370,3467,3458,3488,3372,3374,3376,3377,3379,3380,3381,3382,3384,3385,3386,3387,3388,3389,3391,3393,3395,3397,3399,3400,3402,3403,3405,3406,3407,3408,3409,3410,3411,3448,3515,3526,3536,3561,3614,2671)) )