title: SQL selecting rows where one column's value is common across another criteria column
body: <p>I have a cross reference table that looks like this:</p>
  
  <pre><code>id  document_id  subject_id
  1   8            21
  2   5            17
  3   5            76
  4   7            88
  5   9            17
  6   9            76
  7   2            76
  </code></pre>
  
  <p>It matches documents to subjects. Documents can be members of more than one subject. I want to return rows from this table where a given document matches <strong>all</strong> the subjects in a given set. For example, given the set of subjects:</p>
  
  <p>(17,76)</p>
  
  <p>I want to return only rows for documents which match all the subjects in that set (at least) somewhere in the cross reference table. The desired output set given the above set would be:</p>
  
  <pre><code>id  document_id  subject_id
  2   5            17
  3   5            76
  5   9            17
  6   9            76
  </code></pre>
  
  <p>Notice that the last row of the table is not returned because that document only matches one of the required subjects.</p>
  
  <p>What is the simplest and most efficient way to query for this in SQL?</p>