title: SQL query where ALL records in a join match a condition?
body: <p>I have what seems to be a simple problem, but can not figure out the proper solution via SQL. I'm using postgresql specifically.</p>
  <p>Take the following:</p>
  <pre><code>SELECT *
  FROM users INNER JOIN tags
    ON (tags.user_id = users.id)
  WHERE tags.name IN ('word1', 'word2')
  </code></pre>
  <p>This does not do what I need. I want to find users whose tags are ONLY included in the list. If the user has a tag that is not in the list, the user should not be included.</p>
  <p>'user1' tags: word1, word2, word3<br />
  'user2' tags: word1<br />
  'user3' tags: word1, word2</p>
  <p>Given: word1 and word2. I want to prepare a query that returns 'user2' and 'user3'. 'user1' is excluded because it has a tag that is not in the list.</p>
  <p>Hopefully I made this clear. Thanks for your help!</p>