title: Query to select intervals from a table
body: <p>I have a table that defines time intervals. </p>
  
  <pre><code> _______________________________
  | id | description | start_date |
  |____|_____________|____________|
  |  1 | First       |    NULL    |
  |  3 | Third       | 2009-12-18 |
  |  5 | Second      | 2009-10-02 |
  |  4 | Last        | 2009-12-31 |
  |____|_____________|____________|
  </code></pre>
  
  <p>It stores only the start date, the end date is a day before next date that follows.</p>
  
  <p>I would like to have the next result:</p>
  
  <pre><code> ____________________________________________
  | id | description | start_date |  end_date  |
  |____|_____________|____________|____________|
  |  1 | First       |    NULL    | 2009-10-01 |
  |  5 | Second      | 2009-10-02 | 2009-12-17 |
  |  3 | Third       | 2009-12-18 | 2009-12-30 |
  |  4 | Last        | 2009-12-31 |    NULL    |
  |____|_____________|____________|____________|
  </code></pre>
  
  <p>How should I write this query, since a row contains values from other rows?  </p>
  
  <p><em>(I think MySQL function <code>DATE_SUB</code> could be useful.)</em></p>