Find string value inside array id in column

I am storing in a column a list of states that are separated by commas:

Like this: 1,2,3,4,5,6,7,8.. and so on, just their IDs.

Then I am doing a query to get all the rows that have the state with the ID 8, and it works when the list of states has few items.

Answer :
That's not how the IN clause works--you need to use the FIND_IN_SET function to search comma separated values in a single column:

SELECT *  
  FROM partner 
WHERE FIND_IN_SET(8, states) > 0

Realistically, you should not be storing comma delimited data. It's known as denormalized data, and can be difficult to get information on specific values within the commas.

Source :
https://stackoverflow.com/questions/3876428/why-doesnt-this-mysql-in-1-2-3-4-condition-work-if-there-are-many-values-i

Comments