I understand you want to check if there are any reservations at the specified time. There are 4 hypotheses for such a condition to be true.
- There is a reservation prior to start date of the specification and precedes the end date of the specification, i.e., hereafter of the specifications.
- There is a reservation prior to start date of the specification and before the end date of the specification, i.e., amid of the specifications.
- There is a reservation prior to start date of the specification and precedes the start date of the specification, i.e., ends among the specification.
- There is a reservation prior to end date of the specification and precedes the end date of the specification, i.e., begins among the specification.
Seen that the where
condition would be as follows (among many others):
SELECT *
FROM intranet_reuniao
WHERE resId = 5
AND ( ( reuDataInicio >= '2019-02-26 14:30:00'
AND reuDataInicio <= '2019-02-26 16:30:00')
OR
( reuDataTermino >= '2019-02-26 14:30:00'
AND reuDataTermino <= '2019-02-26 16:30:00')
OR
( reuDataInicio <= '2019-02-26 14:30:00'
AND reuDataTermino >= '2019-02-26 16:30:00')
)
;
Thus, the specification it has starting value before of reuDataInicio and end value hereafter of reuDataInicio, fits condition 1 and 3 of the above list. The other condition is that if the specification has starting value before of reuDataTermine and end value hereafter of reuDataTermine, fits condition 1 and 4 of the above list. The last condition refers to condition 2 of the above list.
This will bring the reservations that exist between the specified time.
I believe he returns blank because he’s picking up from 2:30, and this time has no record.
– Gabriella Selbach