Hello Folks, I have these two tables <code> CREATE TABLE room ( room_number numeric(9) not null, room_type varchar(20) not null, room_fare numeric(9, 2) not null, room_description varchar(255) not null, CONSTRAINT room_number_pk PRIMARY KEY (room_number) ); CREATE TABLE room_reservation ( room_reservation_id varchar(20) not null, room_number numeric(9) not null, client_username varchar(20) not null, room_reservation_start_date date not null, room_reservation_end_date date not null, room_reservation_status varchar(20) not null, CONSTRAINT room_reservation_id_pk PRIMARY KEY (room_reservation_id), CONSTRAINT fk_room_number FOREIGN KEY (room_number) REFERENCES room(room_number), CONSTRAINT fk_client_username FOREIGN KEY (client_username) REFERENCES client(client_username) ); </code> I want to make a query to check if a room is reserved for a particular date or not. Suppose a room is reserved from 22nd April 2012 to 24rd April 2012, then if I check room availability From 27th April 2012 to 30 April 2012 then result = room available From 21th April 2012 to 23 April 2012 then result = room not available From 19th April 2012 to 22 April 2012 then result = room not available I tried to make this query lot but i am not getting success, little help will also work. Thanks, Jimmy
try something like select * from room_reservation left outer join room on room.number = room_reservation.number where room_reservation.room_reservation_id is null if you use a tool like SqlYog or Toad the query builders will help alot.