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