I have a column in a database with values stored as a comma separated array; let's say a sample entry in the database would be: 1, 5, 8, 15
I am trying to use this data now in a SELECT statement to allow a user to select an entry in the database where that array contains the value they select (the values are tied to a look-up table I join in the actual application, the user does not see the integers).
My simplified SELECT statement is essentially:
$arrayvalue = "1";
$query = "SELECT * FROM table WHERE tablearray IN ($arrayvalue)";
For this example I put in 1 as the array value one would be searching for; in actuality that variable is populated by POST from form input the user has control of.
'tablearray' is the name of the column containing the comma separated array that we said would contain 1, 5, 8, 15 as an example (though it varies in reality).
This statement with the IN clause works fine for me right now for data in the table column that has only one value, or with multiple values in the array when I select for the very first value in the array, but does not return for the second value if I select for that i.e. if I were to set $arrayvalue to 1 it works, but to 5 it does not return that row in my results.
I do not need to select for multiple values from the array at this time, I just want it to work to select for one value from the table column regardless of where that integer falls in the array. I suspect I am missing something simple here, thanks if you can help.