title: MySQL Count data for last 7 days
body: <p>I have the following schema.</p>
  
  <p>Table votes</p>
  
  <pre><code>+------------------+--------------+------+-----+---------------------+----------------+
  | Field            | Type         | Null | Key | Default             | Extra          |
  +------------------+--------------+------+-----+---------------------+----------------+
  | id               | int(10)      | NO   | PRI | NULL                | auto_increment |
  | aid              | varchar(10)  | NO   |     |                     |                |
  | ip               | varchar(100) | NO   |     |                     |                |
  | host             | varchar(200) | NO   |     |                     |                |
  | timestamp        | varchar(20)  | NO   |     | 0000-00-00 00:00:00 |                |
  | user             | tinytext     | NO   |     | NULL                |                |
  | userid           | int(10)      | NO   |     | 0                   |                |
  +------------------+--------------+------+-----+---------------------+----------------+
  </code></pre>
  
  <p>Here I want to get the count of each aid on a day for the last 7 days with "0"s for the dates where there a no votes for aid. timestamp is unix timestamp here.</p>
  
  <p>Any help is highly appreciated.</p>