You could increment a user variable @p
only if the checkin_date is not consecutive with the prior row, that is if the date increases by more than 1 day.
SELECT IF(checkin_date <= @d + INTERVAL 1 DAY, @p, @p:=@p+1) AS p, @d:=checkin_date AS d
FROM (SELECT @p:=0, @d:='1900-01-01') _init, mytable
ORDER BY checkin_date;
+------+------------+
| p | d |
+------+------------+
| 1 | 2012-02-01 |
| 1 | 2012-02-02 |
| 1 | 2012-02-03 |
| 2 | 2012-03-01 |
+------+------------+
Then use the above as a subquery, grouping by the p
column, and return a string of the min to max range or else just one value if the count within the group is 1.
SELECT IF(COUNT(*) > 1, CONCAT(MIN(d), ' - ', MAX(d)), MAX(d)) AS date_range
FROM (
SELECT IF(checkin_date <= @d + INTERVAL 1 DAY, @p, @p:=@p+1) AS p, @d:=checkin_date AS d
FROM (SELECT @p:=0, @d:='1900-01-01') _init, mytable
ORDER BY checkin_date) AS t
GROUP BY p;
+-------------------------+
| date_range |
+-------------------------+
| 2012-02-01 - 2012-02-03 |
| 2012-03-01 |
+-------------------------+