title: Filter by many elements in a many to many relationship without using HAVING?
body: <p>Is there a way to write a parametric SQL query that matches notes linked to multiple projects without using <strong>HAVING</strong> ?</p>
  
  <p><a href="http://sqlfiddle.com/#!2/e502d/6" rel="nofollow">SQLfiddle</a></p>
  
  <p>Say I have a "notes" table, a "projects" table and a "notes_projects" table linking these two together. I want to find the notes linked to all the project ids in the <strong>IN</strong> clause. Here is a version with <strong>HAVING</strong>:</p>
  
  <pre><code>SELECT notes.*, COUNT(np.project_id) AS np_count
  FROM notes
  INNER JOIN notes_projects AS np
    ON np.note_id = notes.id
  WHERE np.project_id IN (?)
  GROUP BY notes.id
  HAVING np_count = 2;
  </code></pre>
  
  <p>Is there a way to not use the <strong>HAVING</strong> clause or is this the correct way to handle such cases ?</p>