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 'WHERE FldBpPrimBestellung IN (1373,2376,42853,42944,43466,43608,43628,44416,4447' at line 1SELECT DISTINCT(FldAtPrimkey) FROM TblShopBestellPos JOIN TblShopArtikel ON (FldBpArtikelId = FldAtArtikelId) JOIN TblShopArtikelKat ON (FldAkPrimArtikel = FldAtPrimkey WHERE FldBpPrimBestellung IN (1373,2376,42853,42944,43466,43608,43628,44416,44477,46216,47954,48242,48254,49839,50151,50431,50571,53082,54294,55260,56137,56686,57297,59311,59420,59499,59636,60932,62488,63629,63870,65648,67748,68409,68507,69591,71552,72677,72959,74622,76669,76921,77014,77106,77118,77138,77145,77216,77328,77351) AND FldAkSegmentNr IN(1,0) AND FldAtGeloescht = 0 AND UPPER(FldAtStatus) NOT IN ('GESPERRT','INAKTIV','SYSTEM') AND FldAtWebAnzeige = 1 AND FldAtArtikelId != '91043' ORDER BY RAND() LIMIT 6