I tried using "Exist" and "IN". Not only did I not succeed, it didn't seem as an efficient solution.
Here is a simplified example:
TblMyTable
UserName1 - Grade - UserName2 - Grade
I need a query where there is a mutual relation / existence.
What I mean is that the returned result from the query will only include the users where on the same row there is both UserName1 and UserName2 mutually (see image below for a better example / explanation).
Any user can work with any other user.
So the result will be (the order doesn't matter) ideally in one line:
John - 5000 -- Mary - 3000
or
Mary - 3000 -- John - 5000
The punchline is, it's one dynamically changing table with active Users using the F.Key to the main User's table, which has the P.Key.
Please see image below for a better example / explanation.
Database is SQL 2005.
Many thanx in advance
* Edit: Screenshot that hopefully help explain it all.
The end result should be 2 rows, because only they have a mutual relation in TblDynamicUserList:
ana - Phone - 3000 --- RanAbraGmail - Wifi - 2000
and
anaHeb - Phone - 5000 --- RoyP - Phone - 4000