title: MySQL - AND query on joined table
body: <p>I have a pretty long SQL query:</p>
  
  <pre><code>SELECT *, content.contentID AS thisID
  FROM content
  LEFT JOIN link_keywords ON content.contentID = link_keywords.contentID
  LEFT JOIN link_countries ON content.contentID = link_countries.contentID
  LEFT JOIN link_sections ON content.contentID = link_sections.contentID
  WHERE status = '1' AND typeID = '1'
  GROUP BY contentID
  ORDER BY creationDate DESC
  </code></pre>
  
  <p>I get back a set of results, what I would like to do is display all results where <code>sectionID</code> (which comes from the link_sections join) is equal to both 3 or 4. In other words, all results that are in both section 3 and 4.</p>
  
  <p>The following query doesn't return back anything, presumably this is because it is checking for a single row with <code>sectionID</code> equal to 3 and 4. What I need is any <code>content.contentID</code> with <code>sectionID</code> equal to 3 and 4.</p>
  
  <pre><code>SELECT *, content.contentID AS thisID
  FROM content
  LEFT JOIN link_keywords ON content.contentID = link_keywords.contentID
  LEFT JOIN link_countries ON content.contentID = link_countries.contentID
  LEFT JOIN link_sections ON content.contentID = link_sections.contentID
  WHERE status = '1' AND typeID = '1' AND (sectionID = '3' AND sectionID = '4')
  GROUP BY contentID
  ORDER BY creationDate DESC
  </code></pre>