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 'ORDER BY sequenza,materiale' at line 1---SELECT id FROM materiali WHERE nascosto=0 AND ecommerce=1 AND idcategoria= ORDER BY sequenza,materiale