I have a MySQL table like below:
| ID | userIDs --------------- | 1 | 4,3,5 | 2 | 2,3 | 3 | 1,2,3
I want to retrieve all the rows in which userIDs doesn’t contain 1. I tried
SELECT * FROM tablename WHERE 1 NOT IN (userIDs)
But it’s not working.
Advertisement
Answer
Use FIND_IN_SET
SELECT * FROM tablename WHERE find_in_set(1, userIDs) = 0