title: mysql group_concat only if consecutive dates
body: <p>I have a table with  a date field. I need a query to group_concat the dates only if they are consecutive, otherwise return them individually. </p>
  
  <p>So, for example , if my table has the following data:</p>
  
  <pre><code>+---------+--------------+
  | user_id | checkin_date |
  +---------+--------------+
  |       1 | 2012-02-01   |
  |       2 | 2012-03-01   |
  |       3 | 2012-02-03   |
  |       4 | 2012-02-02   |
  +---------+--------------+
  </code></pre>
  
  <p>I need a query that would return the following results</p>
  
  <pre><code>+--------------------------+
  | checkin_period           |
  +--------------------------+
  | 2012-02-01 - 2012-02-03  |
  | 2012-03-01               |
  +--------------------------+
  </code></pre>
  
  <p>As you can see, feb 1st, 2nd and 3rd have been grouped in 1 row (with only the first and last day being displayed), whereas March 1st is by itself...</p>
  
  <p>I have no idea where to start!</p>
  
  <p>Thanks in advance,</p>
  
  <p>Alain</p>