I am trying to write a query to determine the number of consecutive days that a conference room is available. The conference room is reserved for an entire day. People want to reserve the conference room for X number of days. They provide me with the starting day, ending day, and number of days the conference room is needed.
HOWEVER, we have 7 different conference rooms and conference room #1 may be available for 3 of the five days, but conference room #2 is available for the other two days. I don't want to say there is no conference room is available, but I do want to indicate that they will need to "room hop" between conference rooms.
I want to give a message like the following.
Room #1 is available for the first 3 days (20-Oct-2008 to 22-Oct-2008)
and
Room #2, 3, 4 is available for the last 2 days. (23-Oct-2008 to 24-Oct-2008)
-----
Table structure
Expand|Select|Wrap|Line Numbers
- CREATE TABLE `tbl_availability` (
- `id_avail` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
- `id_room` INT NOT NULL ,
- `id_date` BIGINT NOT NULL ,
- `str_avail_status` VARCHAR( 1 ) NOT NULL,
- `ts_last_update` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
- `str_updated_by` VARCHAR( 35 ) NULL ,
- INDEX ( `id_room` , `id_date` )
- ) ENGINE = MYISAM COMMENT = 'lists current room availabiltiy';
Sample data would look like
Expand|Select|Wrap|Line Numbers
- id_avail id_room id_date str_avail_status last_update str_updated by
- 1234 1 20081020 A
- 1235 1 20081021 A
- 1236 1 20081022 A
- 1237 1 20081023 N 5-Oct-2008 RR
- 1238 1 20081024 N 5-Oct-2008 RR
- 1240 2 20081020 N 5-Oct-2008 RR
- 1241 2 20081021 A
- 1242 2 20081022 N 5-Oct-2008 RR
- 1243 2 20081023 A
- 1244 2 20081024 A
Thanks for reading...any suggestions are greatly appreciated.
--EasyTarget