title: Mysql: how to select groups having certain values?
body: <p>Say there is such table:</p>
  
  <pre><code>mysql&gt; SELECT * FROM tags;
  +---------+--------+
  | post_id | tag_id |
  +---------+--------+
  |       1 |      2 |
  |       1 |      3 |
  |       1 |      1 |
  |       2 |      1 |
  |       2 |      2 |
  +---------+--------+
  5 rows in set (0.00 sec)
  </code></pre>
  
  <p>Field names are pretty self-explanatory. I want to select <code>post_id</code>s that have both 1 and 3 <code>tag_id</code>s, so in this example it's only <code>1</code>. I thought of something like 
  <code>SELECT post_id FROM tags GROUP BY post_id HAVING ...</code> After having I'd like to list <code>tag_id</code>s that are present in this group. How do I do that?</p>