title: Getting rows that contain key1 and don't contain key2
body: <p>I have 3 tables that look like this:</p>
  
  <ul>
  <li><p>Table 1 (main table):</p>
  
  <pre><code>item_id (item_id, item_name) // item_id set to primary 
  row1    (1,       "item 1")
  row2    (2,       "item 2")
  row3    (3,       "item 3")
  </code></pre></li>
  <li><p>Table 2 (linking table):</p>
  
  <pre><code>item_keywords (ikid, #item_id, #keyword_id) // ikid is set to primary 
  row1          (1,       1,     1)
  row2          (2,       1,     2)
  row3          (3,       1,     3)
  row4          (4,       2,     1)
  row5          (5,       3,     1) 
  </code></pre></li>
  <li><p>Table 3:</p>
  
  <pre><code>keywords (keyword_id, keyword_name) // keyword_id is set to primary 
  row1          (1,       "key1")
  row2          (2,       "key2")
  row3          (3,       "key3")
  row4          (4,       "key4")
  row5          (5,       "key5") 
  </code></pre></li>
  </ul>
  
  <p>I would like to make a query that returns all items that contain certain keywords AND also don't contain some other keywords.</p>
  
  <p>If you look at the table data above you can see that: </p>
  
  <pre><code>Item 1 contains keywords with ids: 1,2 and 3; 
  Item 2 contains keyword with id: 1 
  item 3 contains keyword_id =1 
  </code></pre>
  
  <p>So I need a query that will return all items that contain <strong>key1</strong> (keyword_id=1) and DON'T contain <strong>key3</strong> (keyword_id=3). In this exmaple the query should return key2 (keyword_id=2), key3 (keyword_id=3). </p>
  
  <p>Something like this:  </p>
  
  <pre><code>SELECT a.*
  FROM items a
  JOIN item_keywords b ON b.item_id = a.item_id
  WHERE b.keyword_id = 1
     AND b.keyword_id != 3
  </code></pre>
  
  <p>But this doesn't work properly because the query returns key1,key2 and key3. The answer should be: key2 and key3. What would be the simplest way of doing this?</p>