Searching w/ Comma Delimited Field
I'm trying to search a table based on categories. I currently have categories stored in a mediumtext field with their ids separated by commas.
Ex. categories = '01,02,03'
I have a search box that allows a person to select the categories to filter by (using checkboxes). Once those categories are selected, I need to run a query to see which users have at least one of those categories in their categories field.
The issue I have is that I need to do this within the query and the categories field contains multiple values instead of just one. For each category that was checked in the form, I need to see if that id exists within the categories field.
I tried placing the id first and then comparing it to the field:
Ex. '$id' IN (categories)
That didn't seem to work although it didn't give any MySQL errors. I thought that maybe it didn't recognize that categories was actually the field vs a string.
Is there a special function I could use to accomplish what I'm looking to do?