I have and array with two values and I want to use it with sql IN operator in select query.
Here is the structure of my table
id comp_id
1 2
2 3
3 1
I have an array $arr
which have two values Array ( [0] => 1 [1] => 2 )
I want to fetch the record of comp_id 1 and comp_id 2. So I wrote the following query.
SELECT * from table Where comp_id IN ($arr)
But it does not return the results.
SELECT * from table Where comp_id IN (Array)
is not right. Trying to concatenate an array to a string doesn't automatically turn it into a comma separated list of words. – Dan Grossman Mar 8 '12 at 13:23$arr
is probably not an array. Hence, the problem probably doesn't match the question :) If my call was in error, please flag your question for moderator attention. – Tim Post♦ Mar 8 '12 at 19:35