I'm having a bit of a SQL n00b moment. Say I have a property website with two tables: properties
and features
, with a table that joins them. If I have a search form, how can I structure my query to select only properties with all of the selected criteria?
For example, criteria would be POSTed in the form of an array from checkboxes:
Array
(
[features] => Array
(
[0] => 1
[1] => 2
[2] => 5
)
)
How can I select records from my properties
that have features with the IDs of 1, 2 and 5 (and possibly others), but properties that only have one or two are not matched?