title: SQL Query for multiple values and multiple keys in the same table
body: <p>Every post has two post meta:  year and month (custom)</p>
  
  <p>I need SQL query to pull all posts that have </p>
  
  <p>wp_postmeta.meta_key = year AND wp_postmeta.meta_value = 2013 </p>
  
  <p>AND AT THE SAME TIME another meta_key / meta_value pair </p>
  
  <p>wp_postmeta.meta_key = month AND wp_postmeta.meta_value BETWEEN 1 AND 12 ;</p>
  
  <pre><code>SELECT * FROM wp_postmeta
  WHERE (meta_key = 'agam_post_options_year' AND meta_value = 2013)
      OR (meta_key = 'agam_post_options_month' AND meta_value BETWEEN 0 AND 12 )
  GROUP BY meta_value; 
  </code></pre>
  
  <p>This is something I tried and a couple of more variations but it doesn't do much... this specifically gives me one post that has year 2013 and 12 posts that have either 1 or ... to 12 for month field}</p>