title: Select user having qualifying data on multiple rows in the wp_usermeta table
body: <p>I am trying to find the <code>user_id</code> which has all four qualifying values -- each in a different row of the database table.</p>
  <p>The table that I am querying is <a href="https://codex.wordpress.org/Database_Description#Table:_wp_usermeta" rel="nofollow noreferrer"><code>wp_usermeta</code></a>:</p>
  <pre><code>Field       Type                   Null    Key    Default    Extra
  ---------------------------------------------------------------------------
  umeta_id    bigint(20) unsigned            PRI               auto_increment
  user_id     bigint(20) unsigned            IND    0  
  meta_key    varchar(255)           Yes     IND    NULL   
  meta_value  longtext               Yes            NULL   
  </code></pre>
  <p>I have written a MySQL query but it doesn't seem to be working, because the result is empty.</p>
  <pre><code>$result = mysql_query(
       &quot;SELECT user_id 
        FROM wp_usermeta 
        WHERE 
           (meta_key = 'first_name' AND meta_value = '$us_name') AND         
           (meta_key = 'yearofpassing' AND meta_value = '$us_yearselect') AND 
           (meta_key = 'u_city' AND meta_value = '$us_reg') AND 
           (meta_key = 'us_course' AND meta_value = '$us_course')&quot;
  );
  </code></pre>
  <p>How do I return the <code>user_id</code> that relates to all four of these rows?</p>