title: SQL SELECT multiple keys/values
body: <p>I've got a table <code>PERSON_PROPERTIES</code> that resembles the following : </p>
  
  <pre><code>|   ID   |   KEY    |    VALUE     |   PERSON_ID   |
  |    1   |   fname  |    robert    |       1       |
  |    2   |   lname  |    redford   |       1       |
  |    3   |   fname  |    robert    |       2       |
  |    4   |   lname  |    de niro   |       2       |
  |    5   |   fname  |    shawn     |       3       |
  |    6   |   nname  |    redford   |       3       |
  </code></pre>
  
  <p>I would like to <code>SELECT</code> (in JPQL or in PSQL) the <code>PERSON_ID</code> that matches the given <code>fname</code> and <code>lname</code>.</p>
  
  <p>I've tried </p>
  
  <pre><code>`SELECT DISTINCT *
  FROM PERSON_PROPERTIES t0
  WHERE ((((t0.key = 'fname')
  AND (t0.value    = 'robert'))
  AND ((t0.key     = 'lname')
  AND (t0.value    = 'redford'))))`
  </code></pre>
  
  <p>but it returns me no value.</p>
  
  <p>I've also tried </p>
  
  <pre><code>`SELECT DISTINCT *
  FROM PERSON_PROPERTIES t0
  WHERE ((((t0.key = 'fname')
  AND (t0.value    = 'robert'))
  OR ((t0.key      = 'lname')
  AND (t0.value    = 'redford'))))`
  </code></pre>
  
  <p>but this way it returns me all values. I don't know how to turn the query properly for it to give me only value <code>1</code>.</p>