1
Hello,
in the following query, an error is shown in the:
select
fto.id_taxon,
fto.cd_sexo as fto_cd_sexo,
fto.cd_idade as fto_idade,
x.ftv_cd_sexo,
x.ftv_cd_idade,
x.id_fv
from
tb_foto_ocorrencia fto
left join (
select
ftv.id_taxon as id_t,
ftv.cd_sexo as ftv_cd_sexo,
ftv.cd_idade as ftv_cd_idade,
ftv.id_foto_ocorrencia as id_fo,
ftv.id_foto_validacao as id_fv,
sum(
case when ftv.id_taxon <> fto.id_taxon then 1 else 0 end
)
from
tb_foto_validacao ftv
group by
id_fo
) x on fto.id_foto_ocorrencia = x.id_fo
WHERE
fto.fl_validado = 'n'
ORDER BY
`fto`.`id_foto_ocorrencia` ASC
The error shown is as follows::
1054 - Unknown column 'Fto.id_taxon' in 'field list'
But as can be seen in the query, the fields are defined.
The table has this column
id_taxon
?– Sergio
Yes, as seen in the external select.
– Elliott Chaves
The error occurs in the case line when comparing: case when ftv.id_taxon <> Fto.id_taxon then 1 Else 0 end
– Elliott Chaves
A name for the column of
sum()
in subquery. The problem must be caused by this.– Thiago Lunardi