I have table called booked meeting and following is the table structure
meeting table
id | meeting_name | from_time | to_time | date
Following are the structure
CREATE TABLE `bookings` (
`id` int(11) NOT NULL,
`meeting_name` varchar(255) DEFAULT NULL,
`from_time` time DEFAULT NULL,
`to_time` time DEFAULT NULL,
`date` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `bookings` (`id`, `meeting_name`, `from_time`, `to_time`, `date`) VALUES(
(1, 'meeting1', '09:00:00', '10:30:00', '2018-07-26'),
(2, 'meeting2', '11:40:00', '12:25:00', '2018-07-26');
(3, 'meeting3', '03:40:00', '04:25:00', '2018-07-26'););
and here i am trying find available slots between two time suppose if i enter from time
as 10:00:00
and to time
as 01:00:00
then it should return all the meetings between this time and need to find out available timing between them
I am new to mysql so tried few queries but didn't got expected result
SELECT *
FROM `bookings`
WHERE bookings.from_time>="10:00:00" and bookings.to_time<="01:00:00"
SELECT *
FROM `bookings`
WHERE bookings.from_time>="10:00:00" or
bookings.to_time<="10:00:00" or
bookings.from_time>="01:00:00" or
bookings.to_time<="01:00:00"
Expected Result if i pass time between 10:00:00.00 to 13:00:00 then it should return
and also available slots like
10:31:00 to 11:39:00
12.26 to 03:49:00