I have a PHP array: Array(keyword1,blah0,blah1,blah2) and an SQL query.
In the query I want to find if one of the data in Array exists in one of the few columns selected (columnA|columnB|columnC) and fetch that row if true.
I think this is what you want. I couldn't tell if you wanted to check every column for every value in your array.
SELECT * FROM tableName
WHERE columnA = $phpArray[0] OR
columnA = $phpArray[0] OR
columnB = $phpArray[0] OR
columnC = $phpArray[0] OR
columnA = $phpArray[1] OR
columnB = $phpArray[1] OR
columnC = $phpArray[1] OR
columnA = $phpArray[2] OR
columnB = $phpArray[2] OR
columnC = $phpArray[2] OR
...
columnC = $phpArray[n];
You can use PHP to create this statement in a loop
$sql = "SELECT * FROM tableName WHERE ";
for($i=0;$i<count(phpArray)-1;$i++){
$sql .= "columnA = "+"'"+$phpArray[$i]+"'"+ OR "
$sql .= "columnB = +"'"+$phpArray[$i]+"'"+ OR "
$sql .= "columnC = +"'"+$phpArray[$i]+"'"+ OR "
}
$sql .= "columnA = +"'"+$phpArray[$i]+"'"+ OR "
$sql .= "columnB = +"'"+$phpArray[$i]+"'"+ OR "
$sql .= "columnC = +"'"+$phpArray[$i]+"'"+;"
*send sql query
edit: Fixed errors in code
IN is more readable.IN statements, so I learned something out of this. :)