As I search for results I find a lot of answers were the mysql contains the needle and PHP provides the haystack... any array.
I need it the other way around. My table has a column called supervisor_ids containing an array such as this...
a:2:{i:0;i:9999;i:1;i:1;}
In my PHP code I have a value saved in a variable... $supervisor
How do I search the 'supervisor_ids' column for $supervisor?
I would assume something like...
SELECT * FROM my_table WHERE $supervisor IN 'supervisor_ids' but that doesn't work
UPDATE
I just found out that if the table column contains an list like 9999,1,5,678 as opposed to an array... a:2:{i:0;i:9999;i:1;i:1;}
this would work...
SELECT * FROM my_table WHERE FIND_IN_SET($supervisor,supervisor_ids)
What is the equivalent to search it when it is an array?
"SELECT * FROM my_table WHERE 'supervisor_ids' LIKE '%" . $supervisor . "%' ". TheLIKEoperator will search for a pattern and the%acts as a wildcard matching 0 or more characters. TheREGEXPoperator could also work