Note: Data is already stored in this format.
I'm trying to match two comma separated values.
Table records:
user_id state_id city_id role_id
1 1,2,3 1,2 3,4
2 5,6,8,10 9,11,15 1,2
3 7,8 10 2,5
I want to match column values with given values.
Each column should match one or more values.
Tried:
SELECT user_id
FROM users
WHERE
CONCAT(',', state_id, ',') LIKE '%,5,10,%' AND
CONCAT(',', city_id, ',') LIKE '%,9,15,%' AND
CONCAT(',', role_id, ',') LIKE '%,1,%'
Expected output is user id "2" as it is matching given values but above query generating empty result.