I am working on a social website project, and I need to list the contacts "first, second and third degree contacts" of my contacts. I am using SQL Server And C #
Suppose the contact table is as follows:

For contact of the first degree:
- If
gulsah , then my first degree contacts are burak,sennur
The query that I use to select this:
SELECT contact_2 FROM Contacts_Table WHERE contact_1 like 'gulsah'
For a second degree contact:
If gulsah is me again, then my contacts are second degree: mali
What prevents you from choosing the contacts of my contacts, which are not my first contact person.
I can choose reciprocal contacts, but I think this is the wrong approach.
For example, to select the mutual contacts of me ( gulsah ) and burak :
SELECT contact_1 FROM (SELECT * FROM Contact_Test WHERE contact_2 like 'burak') a INNER JOIN (SELECT contact_1 FROM Contact_Test WHERE (contact_2 = 'gulsah')) b ON a.contact_1 = b.contact_1
This query works, but, as I said, this is not the right approach for this to work.
For contact of the third degree:
If gulsah is me again, then my third degree contacts are_ mehmet,ahmet
I need to select the contacts of my contacts, which are not my contacts of the first and second degree :)
Here is a post from Linkedin explaining the contact level.
Thanks for answers.