我正在使用 postgresql 9.1 给定表创建数据库:
CREATE TABLE rooms(
room_number int,
property_id int,
type character varying,
PRIMARY KEY (room_number, property_id)
);
Insert into rooms values (1,1,double),(2,1,double),(3,1,triple)
CREATE TABLE reservations(
reservation_ID int,
property_id int,
arrival date,
departure date,
room_num int,
PRIMARY KEY(reservation_ID,property_id)
FOREIGN KEY (room_number, property_id)
);
INSERT INTO orders VALUES (1,1,2013-9-27,2013-9-30,1),
(2,1,2013-9-27,2013-9-28,2),
(3,1,2013-9-29,2013-9-30,3);
我想给出 2 个日期并检查两者之间的可用性。所以在第一列应该出现:
给定和之间的所有日期
为每种类型的房间增加一栏显示空房情况。
所以我的结果,给定 2013-9-27 & 2013-9-30 作为输入,一定是这样的: