I have a table of type records(ID, ParentID) containing this data:
ID ParentID 1 null 2 1 3 2 4 2 5 3 6 null 7 6
If you draw this table in the hierarchy as a family, 1,2,3,4,5 will be related to each other.
I want to find a way to pass an identifier (e.g. 3 ) so that it gives me other family members. I use C # and SQL, or I'll do it - I want to find the following result:
3 - result 1,2,4,5 2 - result 1,3,4,5 6 - result 7 and so on
I want to find the parent of the identifier that I pass, grandparents, children and grandchildren (as in my example).
source share