title: How to select multiple values from single column with multiple tables in MySQL?
body: <p>I have the following 3 tables</p>
  
  <p>table1</p>
  
  <pre><code>id    name
  ----------
  1     john
  2     dave
  3     eve
  </code></pre>
  
  <p>table2</p>
  
  <pre><code>table1_id    table3_id
  ----------------------
     1            2            
     1            3
     1            5
     2            2
     2            3
     2            4
     3            1
     3            5
  </code></pre>
  
  <p>table3</p>
  
  <pre><code>id    title
  ------------
  1     blue
  2     orange
  3     green
  4     yellow
  5     black
  </code></pre>
  
  <p>I'm trying to select each table1.name where table3.title = (blue OR orange) AND (green OR black)</p>
  
  <p>so that the output is</p>
  
  <pre><code>name
  ----
  john
  dave
  </code></pre>
  
  <p>This is my query so far that won't get this job done:</p>
  
  <pre><code>SELECT table1.name 
  FROM table1 
  JOIN table2 ON table1.id = table2.table1_id
  JOIN table3 t1 ON table2.table3_id = t1.id
  JOIN table3 t2 ON t1.title = t2.title
  WHERE t1.title IN ('blue', 'orange')
  AND t2.title IN ('green', 'black')
  </code></pre>
  
  <p>Any suggestions would be really appreciated!</p>
  
  <p><strong>UPDATE</strong>
  One more question :)</p>
  
  <p>How to select each table1.name where table3.title = ('green' AND 'orange' AND 'black' AND '...') </p>