Re: appointments availability
Posted by: Peter Brawley
Date: November 18, 2015 04:00PM

CREATE TABLE `avail_apps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date_av` date NOT NULL,
`time_av` time DEFAULT NULL,
PRIMARY KEY (`id`,`date_av`)
) ENGINE=InnoDB AUTO_INCREMENT=7135 DEFAULT CHARSET=utf8

CREATE TABLE `appointments` (
...
`startDate` date NOT NULL,
`startime` time NOT NULL,
`endDate` date NOT NULL,
`endTime` time NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8

Assuming appointments has a primary k apptID, and leaving aside for the moment the possibility of appts that begin one day and end on another day ...

select ...
from avail_apps a
left join appointments p on a.date_av=p.startdate and a.time_av between p.starttime and p.endtime
where p.apptid is null;

Suggestion: forget appointments.enddate and endtime, add duration in minutes or whatever matches likely work patterns.

Options: ReplyQuote


Subject
Written By
Posted
November 02, 2015 01:52PM
November 03, 2015 10:59AM
November 03, 2015 01:14PM
November 11, 2015 11:33AM
November 12, 2015 03:50PM
November 13, 2015 12:21PM
November 16, 2015 12:38PM
November 17, 2015 12:15PM
Re: appointments availability
November 18, 2015 04:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.