I have 3 tables
user
service
userServices
User Table
Id | Name | Status
------------------------
1 | User1 | y
2 | User2 | y
3 | User3 | y
4 | User4 | y
Service Table
Id | ServiceName | Status
------------------------
1 | Service1 | y
2 | Service2 | y
3 | Service3 | y
4 | Service4 | y
User Service Table
Id | UserId | ServiceId | Status
-----------------------------------------
1 | 1 | 1 | y
2 | 1 | 3 | y
3 | 1 | 2 | y
4 | 1 | 4 | y
5 | 2 | 2 | y
6 | 2 | 3 | y
7 | 2 | 4 | y
8 | 3 | 1 | y
9 | 3 | 3 | y
10 | 3 | 4 | y
11 | 3 | 2 | y
I will get service id as comma separated string like 1,2,3
as the input & I need to check that which user provide this all services.
For example; User 1 provides services 1,3,2,4, and 1,2,3 is subset of 1,3,2,4 so this record should be returned.
User 2 provide services 2,3,4, so 1,2,3 is not subset of 2,3,4 then this record should not be returned.
I have tried using FIND_IN_SET with GROUP_CONCAT
of user's id but it doesn't work.