title: MySQL - Select last data inserted in last 5 days skip missing records for days
body: <p>I want to select the data that was inserted in the last 5 days, and if the rows are missing for that day then move on to the previous day, but it always have to return rows from the last 5 days.</p>
  
  <p>The column which i'm trying to match is a DATETIME column</p>
  
  <p>I've tried using this query</p>
  
  <pre><code>select * from `thum_{ROH}`  where date &gt;= NOW() - INTERVAL 5 DAY;
  </code></pre>
  
  <p>Now this return data from 2013-12-24 to 2013-12-22 because data on 2013-12-25 and 2013-12-26
  is not available.</p>
  
  <p>How can i modify the query to make it return the last 5 days data irrespective of missing rows. So in this case it will return data inserted on </p>
  
  <pre><code>2013-12-24
  2013-12-23
  2013-12-22
  2013-12-19
  2013-12-12
  </code></pre>
  
  <p>The days which are missing in between the dates above simply have no rows associated with them so they won't be returned.</p>
  
  <p>I have also tried using </p>
  
  <pre><code>select distinct(date(date)), power from `thum_{ROH}` limit 5;
  </code></pre>
  
  <p>But this only selects some values in a specific date while skips on the rest. What i mean is that there are around 30 or more rows in each day which are present so the above query only returns around 2 or 3 rows per day.</p>
  
  <p>I hope my question makes sense. I've been trying to find a solution without any success. Please provide any sort of advice on how can i achieve this. I would appreciate any help.</p>
  
  <p>Thanks in advance,
  Maxx</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is the table structure in question.</p>
  
  <pre><code>+-----------------+------------------+------+-----+---------+-------+
  | Field           | Type             | Null | Key | Default | Extra |
  +-----------------+------------------+------+-----+---------+-------+
  | thumType        | int(11)          | NO   | PRI | 0       |       |
  | timestamp       | int(10) unsigned | NO   | PRI | 0       |       |
  | rune            | char(15)         | YES  |     | NULL    |       |
  | date            | datetime         | YES  |     | NULL    |       |
  | destruction     | decimal(15,2)    | YES  |     | NULL    |       |
  | restoration     | decimal(15,2)    | YES  |     | NULL    |       |
  | conjuration     | decimal(15,2)    | YES  |     | NULL    |       |
  | alteration      | decimal(15,2)    | YES  |     | NULL    |       |
  | illusion        | int(10) unsigned | YES  |     | NULL    |       |
  | power           | decimal(15,2)    | YES  |     | NULL    |       |
  | magicka         | decimal(15,2)    | YES  |     | NULL    |       |
  | health          | decimal(15,2)    | YES  |     | NULL    |       |
  +-----------------+------------------+------+-----+---------+-------+
  </code></pre>