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 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:
+ --------- + -------- + | 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 | + --------- + ----------- +
Select [ID] from [Database Name] *. Dbo.MembersM Join [database name]. Dbo Restricted R on R.GroupID = M. GroupId WHERE M.GroupID = 505
Comments
Post a Comment