0
I have a people table that has people from funcionarios
, pais
and maes
, I’ve managed to relate everyone.
Just look at the way it returns. I need the maes
stay in the first line, just like the pais
.
SELECT DISTINCT mae.nomepessoa as Mae,''as Pai FROM dbo.bpm_pessoa mae
INNER JOIN dbo.bpm_pessoarelacionamento maerelacionamento on
maerelacionamento.idpessoaprincipal = mae.idpessoa where maerelacionamento.idtiporelacionamentopessoa = 3
UNION
SELECT DISTINCT '' as pai,pai.nomepessoa as pai FROM dbo.bpm_pessoa AS pai
INNER JOIN dbo.bpm_pessoarelacionamento pairelacionamento on
pairelacionamento.idpessoaprincipal = pai.idpessoa where pairelacionamento.idtiporelacionamentopessoa = 2
)
AS RESULTADO
Can you post a summary structure of your tables and what is the expected result? Only with queries is it not clear to me.
– gmsantos
It is the following : the table (dbo.bpm_pessoa) has the data of several people.. To know exactly who is a 'employee or parent of the employee or parent of the employee' this relation is in the table (dbo.bpm_pessoarelationing) where 'idtiporelacionamentopessoa' says the type of people. If it is 2 then the person is 'Father' if it is 3 then it is 'Mother'. I have already managed to do the references.. only it is displaying incorrectly.. i want both parent and parent information to be displayed in the first lines..
– Fabio Henrique
And how to get only the employee lines from the bpm_person table?
– José Diz