SQL select values on multiple rows
<p>If I have a table similar to the following:</p>

<pre><code>+-------------+------------+-----------------+
| instance_id | product_id | option_value_id |
+-------------+------------+-----------------+
|           1 |          1 |               1 |
|           1 |          1 |               2 |
|           1 |          1 |               3 |
|           2 |          1 |               1 |
|           2 |          1 |               3 |
|           2 |          1 |               4 |
+-------------+------------+-----------------+
</code></pre>

<p>How would I create a query to find that instance_id 2 represents an instance of product_id 1 that has option values 1,3 and 4?</p>

<p>For example, I'd like to be able to query the table something like as follows:</p>

<p><code>select instance_id from instances where product_id = 1 'having' option_value_id = 1 and option_value_id=3 and option_value_id=4</code> (obviously this won't actaully work) and get the result</p>

<pre><code>+-------------+
| instance_id |
+-------------+
|           1 |
</code></pre>

<p>Any help or pointers much appreciated</p>