1 2 3 4 5 6 7 8 9 10 11 12 13 14
| SELECT C.ID, C.HOTEL_ID, C.NOM, ETAGE, OVERBOOK, TYPE_CHAMBRE_ID, T.NOM, DESCRIPTION, COULEUR, IMAGE_INDEX, 1 AS LIBRE
FROM CHAMBRE C, TYPE_CHAMBRE T, RESERVATION R
WHERE TYPE_CHAMBRE_ID = T.ID AND R.CHAMBRE_ID = C.ID
AND R.DATE_DEBUT <= CURRENT_DATE AND R.DATE_FIN >= CURRENT_DATE
UNION
SELECT C.ID, C.HOTEL_ID, C.NOM, ETAGE, OVERBOOK, TYPE_CHAMBRE_ID, T.NOM, DESCRIPTION, COULEUR, IMAGE_INDEX, 0 AS LIBRE
FROM CHAMBRE C, TYPE_CHAMBRE T, RESERVATION R
WHERE TYPE_CHAMBRE_ID = T.ID AND R.CHAMBRE_ID = C.ID
AND (R.DATE_DEBUT > CURRENT_DATE OR R.DATE_FIN < CURRENT_DATE)
and C.ID not in (select chambre_ID from RESERVATION where DATE_DEBUT <= CURRENT_DATE AND DATE_FIN >= CURRENT_DATE)
UNION
SELECT C.ID, C.HOTEL_ID, C.NOM, ETAGE, OVERBOOK, TYPE_CHAMBRE_ID, T.NOM, DESCRIPTION, COULEUR, IMAGE_INDEX, 0 AS LIBRE
FROM CHAMBRE C, TYPE_CHAMBRE T
WHERE TYPE_CHAMBRE_ID = T.ID AND C.ID NOT IN (SELECT CHAMBRE_ID FROM RESERVATION) |
Partager