title: How should I filter dates in MySQL?
body: <p>I'm creating a set of "archive" pages that are specified by year and month. In my table I have a <code>datetime</code> field called <code>posted</code>. I want to select all rows that are in a particular month.</p>
  
  <p>I've thought of two solutions:</p>
  
  <p>(1) Use string matching:</p>
  
  <pre><code>SELECT ... WHERE posted LIKE '2009-06%'
  </code></pre>
  
  <p>(2) Use some MySQL extraction functions:</p>
  
  <pre><code>SELECT ... WHERE YEAR(posted)=2009 AND MONTH(posted)=6
  </code></pre>
  
  <p>Which of these will be quicker, and are there any better solutions?</p>