I`ve been trying to make a dayplanner for a meeting room. I have two tables:
1) dayplanner
: day split in 5 minute intervals
Values=00:00:00,00:05:00,00:10:00 ... 23:55:00
2) reservations
: name, start and finish
Values=[john,12:00:00,12:30:00],[bob,14:00:00,14:45:00],etc
My goal is to use one query with two IF statements so i can check the starttime and what lies in between
Like this:
[Time] [reserved] [inbetween]
12:00:00 true true
12:05:00 true true
............................
12:35:00 false false
$query = "SELECT *,
IF(d.dayplanner_time = a.reservations_starttime,'true','false') AS reserved,
IF(d.dayplanner_time > a.reservations_start && d.dayplanner_time < a.reservations_finish,'true','false') AS inbetween
FROM dayplanner d
LEFT JOIN reservations a
ON d.day_time = a.reservations_start OR d.dayplanner_time = a.reservations_finish
WHERE d.dayplanner_time BETWEEN '12:00:00' AND '18:00:00';";
The query gives only one true in the reserverd column but nothing works. I hope you can help me.