Error The multi-part Identifier "..." could not be bound

Asked

Viewed 14,523 times

2

I am trying to make the following select and it returns me the error The multi-part Identifier "..." could not be bound in Importacontratoaux.Contratoid

select AreaReclamacao.Descricao from AreaReclamacao 
inner join Contrato on Contrato.Id = ImportaContratosAux.ContratoId
inner join ImportaContratosAux on ImportaContratosAux.EmpresaId = AreaReclamacao.EmpresaId 
where Contrato.Id = '4100001124'

1 answer

6


The error is because you are trying to access a field not yet mapped in join

In his first join you try to access ImportaContratosAux.ContratoId that is only being carried in the second join to query should be:

select 
    AreaReclamacao.Descricao 
from AreaReclamacao 
    inner join ImportaContratosAux  on ImportaContratosAux.EmpresaId    = AreaReclamacao.EmpresaId 
    inner join Contrato             on Contrato.Id                      = ImportaContratosAux.ContratoId
where Contrato.Id = '4100001124'

See that first is loaded the ImportaContratosAux and then carry out the join with Contrato

Browser other questions tagged

You are not signed in. Login or sign up in order to post.