1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') and categories_id in (10244,10468,154,10386,10389,10271,10387,129,153,10259,12' at line 1 in: [SELECT `categories_id` FROM `products_to_categories` WHERE `products_id` in () and categories_id in (10244,10468,154,10386,10389,10271,10387,129,153,10259,127,10392,10513,10344,10391,10274,253,10559,155,157,156,168,10377,10379,10469,10433,256,158,261,10270,10380,130,132,10390,10265,257,258,10328,259,10269,260,10353,10268,10354,126,10272,262,10331,10381,10382,263,10383,208,10260,264,10384,10360,10406,10447,10242,10241,10385,173,10261,252,254,10409,128,10263,255,10411,10432,193,10267,10361,265,10273,266,10264,10243,267,10262,10368,10266,10362,10363,10364,10365,10366,10367,10369,10370,10372,10388,10371,10373,10374,10375,10376) group by `categories_id` order by FIELD (`categories_id`,10244,10468,154,10386,10389,10271,10387,129,153,10259,127,10392,10513,10344,10391,10274,253,10559,155,157,156,168,10377,10379,10469,10433,256,158,261,10270,10380,130,132,10390,10265,257,258,10328,259,10269,260,10353,10268,10354,126,10272,262,10331,10381,10382,263,10383,208,10260,264,10384,10360,10406,10447,10242,10241,10385,173,10261,252,254,10409,128,10263,255,10411,10432,193,10267,10361,265,10273,266,10264,10243,267,10262,10368,10266,10362,10363,10364,10365,10366,10367,10369,10370,10372,10388,10371,10373,10374,10375,10376)]