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 a.cod_grupo = b.cod_grupo and b.cod_subgrupo = c.cod_subgrupo ORDER BY des_p' at line 1