This one is stumping me, I will just go ahead and explain via SQL. Here is the data structure:
Property
PropertyId Name
1 Property one
2 Property two
Property Features
PropertyFeatureId FeatureId PropertyId
1 1 1
2 2 1
3 1 2
Feature
FeatureId Name
1 Hot tub
2 Wifi
How would I go about finding all properties that have a hot tub AND wifi? So in the example above I would want propery 1, but not 2.
One way I suppose is inner-joining and filtering by the ones we want, but I want to generalize this so I can find all properties with feature A, B, C and so on.
The idea here is to count the number of instances of propertyName and that it is equal to the number of values supplied in the
WHEREclause condition.SQLFiddle Demo