How can I use an array within a SQL query
- by ThinkingInBits
So I'm trying to take a search string (could be any number of words) and turn each value into a list to use in the following IN statement) in addition, I need a count of all these values to use with my having count filter
$search_array = explode(" ",$this->search_string);
$tag_count = count($search_array);
$db = Connect::connect();
$query = "select p.id
from photographs p
left join photograph_tags c
on p.id = c.photograph_id
and c.value IN ($search_array)
group by p.id
having count(c.value) >= $tag_count";
This currently returns no results, any ideas?