(Select Entity1 from CompanyEntity
where Entity2=2 and CompanyID=3 and IsRelation=1)
intersect
(Select Entity2 from CompanyEntity
where Entity1=3 and CompanyID=3 and IsRelation=1)
The above query is the exact query.
The first SELECT statement gives me some number
For eg: 2,4,5,7,9
And the second SELECT statement also results in some numbers.
For eg:1,2,5,7,8
And out of these numbers I want only the common ones like 2,5 ,7
The first and second statement involves only one table i.e. CompanyEntity
Can you help me reformulate??