Frank_Rizzo - 9:24 pm on Jul 30, 2012 (gmt 0)
We all started somewhere!
jecasc. That's the kind of method I would come up with. More from a programming background, rather than an SQL background.
There is probably a select / subselect solution but the problem with this is your n is not fixed so it could get messy.
I would filter for 11,4,7 first and then loop through to find full candidates.
$result = mysql_query("SELECT product_id FROM YOURTABLE
WHERE category_id in(11,14,7) order by product_id, category_id");
this will ensure we only retrieve records that definitely have at least one of the ids thus making your select smaller and easier to manage for your array method.
Now loop through the data for each product_id and do a one shot +1 if there is a match for 14, 11, 7. At the end of the loop just find the array records that have 3 matches.
This should be easy to scale for n.