title: Select row dependent on other rows in the table
body: <p>Apologies if this has been asked before but I really didn't know what to search and thus not sure how to word the question title so fingers crossed. </p>
  
  <p>I'm building quite a common system where one product can have multiple categories and on the front-end, the user can search for products specifying multiple categories.</p>
  
  <p>Say we had the following schema and data ( I cant post images yet, apologies, please see link )- </p>
  
  <p><strong>table name: product_categories</strong></p>
  
  <p>Data: </p>
  
  <p><img src="https://i.stack.imgur.com/s7MaS.jpg" alt="enter image description here"> </p>
  
  <p><em>The products table is very standard - id, name, amount etc.</em></p>
  
  <p>So product 1 has 2 categories.</p>
  
  <p>If the user checks 2 tickboxes on the search page which represent category 2 and 3, how would I query that so only products which have both of those categories come back?</p>
  
  <p>Something such as follows doesn't work, as there is no one row in that which has a category id of 2 AND a category id of 3:</p>
  
  <pre><code>SELECT * from product_categories where `category_id` = 2 AND `category_id` = 3;
  </code></pre>
  
  <p>I've tried using WHERE IN aswell, however, this would return product 1 even if i was looking for products which had both category id 2 and 6 ( for example ) which I don't want.</p>
  
  <p>This is part of a bigger query however, I will be able to apply the solution if I manage to find one.</p>