title: need updation for mysql query for choosing date range for reservation of a hotel room or any thing
body: <p>i had a situation in my project that is as follows.</p>
  
  <p>while checking for the available rooms </p>
  
  <pre><code>$sel_from_bookings="SELECT room_no FROM `booking` WHERE (('".$_POST['req_tdate']."' BETWEEN check_indate AND check_outdate) OR ('".$_POST['req_fdate']."' BETWEEN check_indate AND check_outdate)";
  
  $sel_from_reserv="SELECT room_no FROM `reservation` WHERE (('".$_POST['req_tdate']."' BETWEEN check_indate AND check_outdate) OR ('".$_POST['req_fdate']."' BETWEEN check_indate AND check_outdate))"; 
  
  $sel_rooms="SELECT room_no FROM rooms WHERE room_no NOT IN (".$sel_from_bookings.") AND room_no NOT IN (".$sel_from_reserv.")";
  </code></pre>
  
  <p>The first query retrives the list of room numbers from the booking table which satisfies the daterange</p>
  
  <p>similarly the second one dos same from the table reservation</p>
  
  <p>the last query uses the list provided by the above two queries and gets the list of room which are not in the generated list.</p>
  
  <p>works fine for 10-08-2010 / 15-08-2010</p>
  
  <p>works fine for 20-08-2010 / 25-08-2010</p>
  
  <p>when i give the dates between 10 and 15 it works fine similarly for 20 and 25 and also works fine for the dates 14-08-2010 and 21-08-2010 </p>
  
  <p>but not working for 16-08-2010 to 19-08-2010</p>
  
  <p>need any clarification please ask me.</p>
  
  <p>Thanks.</p>