I have a table to keep friend information, with columns MemberID
and FriendID
. Here is some sample data:
RecordID MemberID FriendID
-------- -------- --------
1 10 12
2 12 10
3 10 14
4 15 10
5 14 12
6 10 13
7 11 13
I need to find the friends of any Member, either in the MemberID
column or the FriendID
column.
For example:
- The friends for
MemberID
10 are 12, 13, 14, 15. - The friends for
MemberID
14 are 10, 12.
I have tried many ways to get the values with a query, but all in vain.
Please suggest the best SQL query to accomplish the task in a single statement.