On Tue, 2009-08-18 at 19:15 +0430, Behzad wrote:
> Dear list,
> I'm faced with an interesting and challenging problem.
> Consider a database, designed for a hotel.
> At any given time, each room has a different status: It's Busy or Reserved,
> or Free.
> It's easy to retrieve number of Free rooms at the current time.
> But how can I count the number of rooms that were busy during the last week
> I would appreciate if you take a brief moment of your time and share your
> Thank you in advance,
Keep a table that lists all the rooms along with their current status
Keep another table that has these fields:
* room_id (the id from above table)
* status (enumerated value - 'busy','reserved')
Then you perform your query using a join of these two tables, within a
particular date range. I've left out 'free' from the second table
because there's no point updating the table for a period if a room is
not being used.
You could also have start_date and end_date as datetime fields, as every
hotel i've ever been in has a set time for check-in and another for
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php