0
I have a table where there are the fields: Personal, Name and Personal (which indicates that she is someone else’s daughter from the table. and if she is the father, that field is null).
I need to extract a result that brings: Name Of Person
0
I have a table where there are the fields: Personal, Name and Personal (which indicates that she is someone else’s daughter from the table. and if she is the father, that field is null).
I need to extract a result that brings: Name Of Person
0
If I understand your question, you want to bring the father’s name along with the person’s name.
For this, you can use a LEFT JOIN
of the Person table with itself, relating the records where the Father’s code is equal to the registry code.
SELECT P.Nome AS NomePessoa,
Pai.Nome AS NomePai
FROM Pessoa AS P
LEFT JOIN Pessoa AS Pai
ON Pai.PessoaId = P.PessoaPaiId
The LEFT JOIN
allows you to bring in records that have no Father, that is, that have no relationship.
Browser other questions tagged sql select hierarchical-data
You are not signed in. Login or sign up in order to post.
Your question does not make much sense. For what you wrote just a SELECT Name FROM your table; and has nothing to do with the title.
– anonimo
Your question is incomprehensible. You want to bring the father’s name along with the person’s name?
– ricidleiv