Error getting data in SQL

3

I have this code:

SELECT Colaborador.IdColaborador, Colaborador.Numero, Colaborador.Nome, Colaborador.[Centro de Custo], Colaborador.Usuario,
Colaborador.Responsavel, Colaborador_1.Nome FROM Colaborador,
Colaborador AS Colaborador_1 WHERE
(((Colaborador_1.IdColaborador)=[Colaborador].[IdColaborador]));

Where I want to get the name of the responsible person who is also an Employee but the result is the Employee name repeated 2 times.

What am I doing wrong?

    
asked by anonymous 07.04.2016 / 23:55

1 answer

4

Certainly you are not making the right relationship.

See where you do it:

(((Colaborador_1.IdColaborador)=[Colaborador].[IdColaborador]))

This will make a JOIN with the same data of your collaborator, what you need and verify the ID of the person in charge to make the relation.

  SELECT Colaborador.IdColaborador, Colaborador.Numero, Colaborador.Nome, Colaborador.[Centro de Custo], Colaborador.Usuario,
Colaborador.Responsavel, Colaborador_1.Nome FROM Colaborador,
Colaborador AS Colaborador_1 WHERE
(((Colaborador_1.IdColaborador)=[Colaborador].[IdResponsavel]));
    
08.04.2016 / 00:06