SET TERMOUT ON
DROP VIEW BP_VIEW;
CREATE VIEW BP_VIEW AS
SELECT b.BOOKINGID,
g.GUESTID,
g.FORENAME, g.SURNAME,
br.FLOORNO, br.ROOMNO,
r.TYPE,
b.TOTALPRICE + (rt.RATE*(b.DEPARTDATE - b.ARRIVEDATE)) AS TOTAL_AMOUNT_DUE
FROM GUEST g, ROOM r
INNER JOIN BOOKING b ON b.BOOKINGID = GUESTID
INNER JOIN BOOKINGROOM br ON b.BOOKINGID = br.BOOKINGID AND r.FLOORNO = br.FLOORNO AND r.ROOMNO = br.ROOMNO
INNER JOIN ROOMTYPE rt ON rt.TYPE = r.TYPE
WHERE (CURRENT_DATE BETWEEN b.ARRIVEDATE AND b.DEPARTDATE);
SELECT * FROM BP_VIEW;
COMMIT;
SET TERMOUT ON
大家好,
我正在尝试执行上面的代码,它执行得很好,但它正在选择更新某些不属于 b.ARRIVEDATE 和 b.DEPARTDATE 之间的 CURRENT_DATE 类别的预订。
通过此声明,我试图查找当前而非过去预订的预订信息。
当代码执行时,结果不是我所期望的。我是否正确完成了 AND 部分?