title: Mysql join two table based on between dates
body: <p>I have a student attendance view in mysql database like below</p>
  
  <pre><code>id    date         grade
  239   01/09/2012   1
  239   02/09/2012   0
  239   04/09/2012   0
  239   05/09/2012   1
  239   07/09/2012   0
  239   25/09/2012   0
  239   26/09/2012   0
  </code></pre>
  
  <p>And i also have a leave application table in database like below. where approved = 1 and rejected = 0. </p>
  
  <pre><code>id  uid    from            to           status
   1   239    04/09/2012    07/09/2012  approved
   2   239    26/09/2012    26/09/2012  rejected
  </code></pre>
  
  <p>Now i want to create a query to display approved leave and final grade of student like below</p>
  
  <pre><code>id    date       grade    leave   Fgrade
  239   01/09/2012   1                 1
  239   02/09/2012   0                 0
  239   04/09/2012   0       1         1
  239   05/09/2012   1       1         1    
  239   07/09/2012   0       1         1
  239   25/09/2012   0                 0
  239   26/09/2012   0                 0
  </code></pre>
  
  <p>Please tell me how can i get this result.</p>