I scratch my head to figure out a solution to the following question:
I have a table with two fields: USER_ID and CLIENT_ID. For each USER_ID, there is 1 to n CLIENT_ID.
Suppose user A is associated with clients 1,2 and 3. I want to build a query that returns other users who are also associated with all of these clients. They can be associated with a large number of clients, but they must have links to all of the clients of user A.
Example: User B has links to clients 1,2,3,4. User C has links to clients 1.2. Then, the request should return User B, since User B has links to all of the clients of User A. User C should not return, since he has only links to some, but not all, of the clients of User A.
This seems like a deceptively simple problem, but I can't come up with a query for my whole life that satisfies my limitations. Are there any experienced SQL gurus who can help me?
source share