Basically, we know that SQL IN is used to replace many OR conditions (x OR y OR z). But in this case I need a query, or a code solution to select all rows that contain (x AND y AND z). Something like <http://www.mobile.de/> is using. On their site, when searching for vehicles the more features you select the less results you get. So they're obviously not using IN in their query. A **really** simplified version of my database would be this.

Adverts table:

```
--------------
| id | title |
--------------

```

Features table:

```
---------------
| id | f_name |
---------------

```

AdvertsFeatures table:

```
-------------------------------
| id | advert_id | feature_id |
-------------------------------

```

For the features search filter I do a LEFT JOIN with the AdvertsFeatures table and apply the following WHERE clause:

```
WHERE feature_id IN (x, y, z)

```

Thus, the Adverts that have **any** of the selected features come up. But like I said, I need a query or a code solution that gets only the Adverts that have **all but not necessarily only** the selected features. A user can select any number of features from a total of around 40 features. That would be a lot of WHERE clause "AND"s, which I already have many of.

How do I go about doing this? It doesn't have to be SQL, it could be a code solution.