title: Select rows from a table where row in another table with same id has a particular value in another column
body: <p>In MySQL:</p>
  
  <p>If we have two tables:</p>
  
  <pre><code>comments
  key    |    value
  =================
  1      |    foo
  2      |    bar
  3      |    foobar
  4      |    barfoo
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>meta
  comment_key    |    value
  =========================
  1              |    1
  2              |    1
  3              |    2
  4              |    1
  </code></pre>
  
  <p>I want to get the comments from the <code>comment</code> table that have a corresponding <code>comment_key</code> in the <code>meta</code> table that have a specific <code>value</code> (the <code>value</code> column in the <code>meta</code> table).</p>
  
  <p>For example, I'd like to select all the rows from the <code>comment</code> table that have a <code>value</code> of <code>1</code> in the <code>meta</code> table:</p>
  
  <p>I'd expect these results:</p>
  
  <pre><code>key    |    value
  =================
  1      |    foo
  2      |    bar
  4      |    barfoo
  </code></pre>
  
  <p>And if I were to select all the rows from the <code>comment</code> table that have a <code>value</code> of <code>2</code> in the <code>meta</code> table:</p>
  
  <p>I'd expect this result:</p>
  
  <pre><code>key    |    value
  =================
  3      |    foobar
  </code></pre>
  
  <p>I really hope someone can help, thank you all in advance!</p>
  
  <p>I think I need to do a join? Any pointers would be great, and if at all possible, a short explanation so I can work out where I was going wrong -> so I'll know for next time!</p>