sql - Querying a table matching all the data of the subquery and all the data should also match with common data -


I have two tables named "Subscription" and "Restricted"

Table: Subscription

  + --------- + -------- + | Group ID | UserID | + --------- + -------- + | 10001 | 605 | | 10001 | 255 | | 10002 | 605 | | 10004 | 222 | | 10003 | 605 | | 10002 | 501 | Table:  restriction  table  restriction  The group is restricted to the restricted group ID and its related content ID.  
  + --------- + ----------- + | Group ID | ContentId | + --------- + ----------- + | 10001 | 33333 | | 10001 | 22222 | | 10002 | 22222 | | 10004 | 44444 | | 10003 | 22222 | | 10002 | 44444 | + --------- + ----------- +   

I want to get ContentID which is related to the user ID of all groups From the restricted table.

that is As sample data of UserID = 605, Group ID is "10001, 10002, 10003", I need to get ContentID which is restricted to all group IDs listed for user 605.

ContentID is required in this case '22222'

The final purpose is to get a list of ContentID that is restricted to all groups of that UserID. If ContentID is not banned in any group, then Content ID is not considered restricted.

The best I can do without knowing the table structures:

  Select [ID] from [Database Name] *. Dbo.MembersM Join [database name]. Dbo Restricted R on R.GroupID = M. GroupId WHERE M.GroupID = 505    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -