title: Wordpress JOIN wp_post and wp_postmeta
body: <p>I am trying to search through wp_post &amp; wp_postmeta simultaneously using this query:</p>
  
  <pre><code>$querystr = "
      SELECT $wpdb-&gt;posts.* 
      FROM $wpdb-&gt;posts, $wpdb-&gt;postmeta
      WHERE $wpdb-&gt;posts.ID = $wpdb-&gt;postmeta.post_id 
      AND $wpdb-&gt;postmeta.meta_key = 'City' 
      AND $wpdb-&gt;postmeta.meta_value = 'Vancouver'
      AND $wpdb-&gt;posts.post_status = 'publish' 
      AND $wpdb-&gt;posts.post_type = 'talents'
      ORDER BY $wpdb-&gt;posts.post_date DESC
   ";
  
  $pageposts = $wpdb-&gt;get_results($querystr, OBJECT);
  </code></pre>
  
  <p>As you can see I search for posts that have City=Vancouver as its meta field. But how do I add one more condition so I won't be getting Vancouver, BC and Vancouver, WA together?</p>
  
  <p>smth like:</p>
  
  <pre><code>    AND ($wpdb-&gt;postmeta.meta_key = 'Country' 
      AND $wpdb-&gt;postmeta.meta_value = 'Canada')
      AND ($wpdb-&gt;postmeta.meta_key = 'City' 
      AND $wpdb-&gt;postmeta.meta_value = 'Vancouver')
  </code></pre>