okay, be glad to
what is the largest range of dates you want to check? the answer will determine how many rows you need in the following table:
Code:
create table integers (i integer not null primary key);
insert into integers (i) values
(0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11), ... ;
let's use your original range of dates, 2005-02-05 through 2005-02-09, as the example range
note this range is only 4 days, so if you wanted a larger range, say 15 days, you gotta make sure you have at least the first 15 integers in your integers table
okay, the way the query works, it uses the integers to generate a date, by adding the integer to the starting date of the range
then it uses a left outer join to match each date in the range to any row whis spans that date, i.e. the generated date is between bookdate and enddate
simple, eh? just run the query and you get results

Code:
select date_add('2005-02-05', interval i day) as thedate
, count(room.id) as bookings
from integers
left outer
join room
on date_add('2005-02-05', interval i day)
between room.bookdate
and room.enddate
where i
between 0
and to_days('2005-02-09')
-to_days('2005-02-05')
group
by thedate
order
by thedate
note that in the above query you would replace '2005-02-05' with a parameter for the starting date, and replace '2005-02-09' with a parameter for the ending date
let me know if you have any questions
Bookmarks