I want to get id's of users who has partners with matching partners id. In users table I am supposed to save partners id as comma separated string. First I get partner id from partners table which is array of ids(multiple record). Then I have to compare this array of ids with partners_id in the users table. How to compare a string with array of values.
Here I tried by converting array of ids to string and then I compared. But it not helped. Someone suggest a way.
Query I tried
SELECT `user`.`userID` FROM `user` WHERE `user`.`groupID` = 1234 AND `user`.`partners_id LIKE (SELECT GROUP_CONCAT(partners.id) as pid FROM `partners` WHERE `partners`.`name` LIKE '%XX%' AND `partners`.`active` = 1)
Table Users
userID groupID partners_id
1 4 1A,2B,3C
2 3 1A
3 4 2B
4 4 5C,2B
Partners
id name active
1A XXSS 1
1B AAYY 0
1C ZZSS 1
2B CCXX 1
3C XXBB 1
5C CCDD 0