SELECT DISTINCT pa.idColor FROM `product_amount` pa INNER JOIN product p ON p.id=pa.idProduct AND p.brands LIKE '%3063%' INNER JOIN product_categories pc ON pc.idProduct=pa.idProduct AND pc.idCategory IN (0,179,127,231,180,241,96,165,136,147,141,150,159,163,152,220,211,170,172,185,239,164,258,265,207,132,246,249,247,156,240,242,243,244,245,250,253,271,269,157,186,256,257,263,267,203,208,158,251,94,187,254,268,270,209,219,237,255,176,216,218,193,217,212,221,232,213,168,192,190,234,235,259,261,260,266,262) WHERE 1=1 ORDER BY pa.amount<=0 , p.id DESC
Array ( [breads] => Array ( [0] => Markalar [1] => Huawei Ascend P7 ) [brand] => 3063 [info] => Array ( [brand] => Huawei Ascend P7