Note that there are some explanatory texts on larger screens.

plurals
  1. POAvailable appointments
    primarykey
    data
    text
    <p>I have two mysql tables, schedule and appointment. In schedule table there is defined doctor termins and in other there are booked appointments. The problem is that the doctor can always change his termins and I can't paste reference in appointments table and I only want to get available termins in one mysql query for both doctors. Is that posible? </p> <pre><code>CREATE TABLE `schedule` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `from` timestamp NULL DEFAULT NULL, `to` timestamp NULL DEFAULT NULL, `doctor_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; INSERT INTO `schedule` (`id`, `from`, `to`, `doctor_id`) VALUES (1, '2012-09-06 14:00:00', '2012-09-06 14:59:59', 1), (2, '2012-09-06 15:00:00', '2012-09-06 15:59:59', 1), (3, '2012-09-06 16:00:00', '2012-09-06 16:59:59', 1), (4, '2012-09-06 17:00:00', '2012-09-06 17:59:59', 1), (5, '2012-09-06 14:00:00', '2012-09-06 14:59:59', 2), (6, '2012-09-06 15:00:00', '2012-09-06 15:59:59', 2), (7, '2012-09-06 16:00:00', '2012-09-06 16:59:59', 2), (8, '2012-09-06 17:00:00', '2012-09-06 17:59:59', 2); CREATE TABLE `appointments` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `from` timestamp NULL DEFAULT NULL, `to` timestamp NULL DEFAULT NULL, `doctor_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; INSERT INTO `appointments` (`id`, `from`, `to`, `doctor_id`) VALUES (3, '2012-09-06 16:00:00', '2012-09-06 16:59:59', 1), (4, '2012-09-06 17:00:00', '2012-09-06 17:59:59', 1), (5, '2012-09-06 14:00:00', '2012-09-06 14:59:59', 2), (8, '2012-09-06 17:00:00', '2012-09-06 17:59:59', 2); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload