title: SQL select with multiple conditions on the same table
body: <p>I have 2 tables in MySQL, the first one has 2 columns: ID and name, the second has 3 columns: firstTableId (foreign key on the first table), key, value.</p>
  
  <p>I have the following rows in table 1:</p>
  
  <ul>
  <li>1,Bob</li>
  <li>2,Alice</li>
  <li>3,Fred</li>
  </ul>
  
  <p>I have the following rows in table 2:</p>
  
  <ul>
  <li>1,age,20</li>
  <li>1,gender,male</li>
  <li>2,age,20</li>
  <li>2,gender,female</li>
  <li>3,age,18</li>
  <li>3,gender,male</li>
  </ul>
  
  <p>I would like to write a select query using only the last 2 columns on the second table (key and value) that returns only Bob form the first table, but I can't seem to figure it out. </p>
  
  <p>Essentially I want to select from the first table all rows where, in the second table, we have key=age and value=20 for one row, and key=gender and value=male in another row. Can anyone point me in the right direction ? Manipulating table structure is not preferred as this is a simplified example and both "key" and "value" columns in the second table can be pretty much anything, it's not actually limited to "age" and "gender".</p>
  
  <p>Thanks in advance.</p>