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 cl.activo_pt = 1 ORDER BY cl.ordem DESC, cl.cod_cliente DESC' at line 1