title: SQL Query to select data based on year and month
body: <p>I'm writing an ecommerce app and im writing a script to track the sales of items according to year/month.</p>
  
  <p>I used this query here to get the distinct year-month dates from the table.</p>
  
  <pre><code>SELECT DISTINCT CONCAT(YEAR(date),'-',MONTH(date)) FROM product_purchases WHERE product_id = 1
  </code></pre>
  
  <p>Which would give me an output like so</p>
  
  <pre><code>2017-11
  2017-12
  </code></pre>
  
  <p>What im trying to accomplish next is to select data that match that year and month, for example 2017-11.</p>
  
  <p>I've tried this query which returned 0 rows</p>
  
  <pre><code>SELECT * FROM product_purchases WHERE DATE(date) = '2017-12'
  </code></pre>
  
  <p>What would be the right way to go about doing this?</p>