in reply to SQL Query for Scheduling
Seems to me that this is an SQL question rather than a perl one, but anyway...
Here is one way to do it using mySQL (if I've understood the question correctly)
Your question was: "I want to find which appointment times are still available"
Therefore, the scheduled_availability table isn't required.. ie. you only need to do a select from two tables
- DarrenCREATE TABLE scheduled_availability ( employeeID int(11) NOT NULL default '0', start datetime default NULL, end datetime default NULL ) TYPE=MyISAM; CREATE TABLE appointments ( employeeeID int(11) NOT NULL default '0', start datetime default NULL, end datetime default NULL ) TYPE=MyISAM; CREATE TABLE times ( start datetime default NULL, end datetime default NULL ) TYPE=MyISAM; INSERT INTO times VALUES ('2005-08-16 16:35:40','2005-08-16 17:35:40') +; INSERT INTO times VALUES ('2005-08-16 17:35:40','2005-08-16 18:35:40') +; INSERT INTO times VALUES ('2005-08-16 18:35:40','2005-08-16 19:35:40') +; INSERT INTO times VALUES ('2005-08-16 19:35:40','2005-08-16 20:35:40') +; INSERT INTO times VALUES ('2005-08-16 20:35:40','2005-08-16 21:35:40') +; INSERT INTO times VALUES ('2005-08-16 21:35:40','2005-08-16 22:35:40') +; INSERT INTO times VALUES ('2005-08-16 22:35:40','2005-08-16 23:35:40') +; INSERT INTO appointments VALUES (1,'2005-08-16 16:35:40','2005-08-16 1 +7:35:40'); mysql> select times.start, times.end from times, appointments where ap +pointments.start != times.start and appointments.end != times.end; +---------------------+---------------------+ | start | end | +---------------------+---------------------+ | 2005-08-16 17:35:40 | 2005-08-16 18:35:40 | | 2005-08-16 18:35:40 | 2005-08-16 19:35:40 | | 2005-08-16 19:35:40 | 2005-08-16 20:35:40 | | 2005-08-16 20:35:40 | 2005-08-16 21:35:40 | | 2005-08-16 21:35:40 | 2005-08-16 22:35:40 | | 2005-08-16 22:35:40 | 2005-08-16 23:35:40 | +---------------------+---------------------+ 6 rows in set (0.00 sec)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SQL Query for Scheduling
by TedPride (Priest) on Aug 16, 2005 at 08:56 UTC | |
by jhourcle (Prior) on Aug 16, 2005 at 12:02 UTC |