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_status_imovel = 1 and a.cod_tipo = b.cod_tipo and a.cod_bairro = c.cod' at line 6