When requesting a vehicle reservation, the system enters the expected departure and return time code (we prefer to work with fixed codes instead of schedules to facilitate scheduling). What happens is that when the reservation is made at times ahead (for example, I'm reserving in the morning a schedule in the afternoon) the system allows another reservation to pass "over" the previous reservation.
For example, if I reserve from 9:00 a.m. to 10:00 p.m., my% cc% does not show this interval after confirmation, but if someone book from 8:00 a.m. to 11:00 p.m. on the same day he will let me record . With select
below I do not display the reserved times, any idea how to do the validation?
SELECT H.* FROM HORARIOS H
WHERE NOT EXISTS (
SELECT * FROM RESERVAS R
WHERE H.COD BETWEEN R.COD_HORA_SAIDA AND
R.COD_HORA_PREVISTA-1 AND
R.COD_VEICULO = :codveiculo AND
DATE_FORMAT(DATA_SAIDA, \'%d-%m-%Y\') = :codcalendario AND
r.ativa = 1)
ORDER BY H.COD
Below is an example of the situation that occurs: