OK, I have looked through many posts, and the MySQL manual scratching my head until gray matter pours from the wounds.
I have a client who has a DB with a field that has values in it that are comma separated.
Let's say the table looks something like this:
and the contents field is a varchar(50)
id | contents
1 | 1,2,3
2 | 2,4,5
3 | 3,4,5
4 | 1,3,5
OK, I want to pull record that only have a 4 in them, so I want the results to be:
2 - 2,4,5
3 - 3,4,5
Then I want to query the table to pull only records with a 1 in them:
1 - 1,2,3
4 - 1,3,5
I can't figure out the query to essentially do a full-text type search on the content fields.
I want to avoid using LIKE %4% because that would also return something like 14 or 41. I have looked into "HAVING" which won't quite work (at least I don't think so). I think I want to use "IN", but can't find any of the documentation in the MySQL manual, because it is a somewhat vague search word for that manual's search function.
Any help would be greatly appreciated.