SELECT npc_types.id,npc_types.class,npc_types.hp,npc_types.exp_pct,npc_types.level,npc_types.scalerate,npc_types.maxlevel,npc_types.race,npc_types.`name`,npc_types.maxlevel,npc_types.loottable_id FROM npc_types WHERE npc_types.id DIV 1000 = AND npc_types.race!=127 AND npc_types.race!=240 GROUP BY npc_types.id ORDER BY name 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 npc_types.race!=127 AND npc_types.race!=240 GROUP BY npc_types.id ORDER B...' at line 2