I have 3 tables. First one is a list of personnel:
Table Personnel
Id_personnel Name
1 John
2 Alice
3 Tom
4 Charles
5 Ben
Second is a table with medical leave:
Table Medical
Id_personnel Start_date End_date
3 2012-08-02 2012-08-05
2 2012-08-02 2012-08-15
4 2012-10-04 2012-10-06
2 2012-10-02 2012-10-15
2 2012-09-20 2012-09-21
Third is a table with holiday leave:
Table Holiday
Id_personnel Start_date End_date
3 2012-08-02 2012-08-05
2 2012-02-02 2012-02-15
5 2012-10-01 2012-10-05
I have two event dates: Symposium_start_date
and a Symposium_end_date
(as variables) and I would like to select all Personnel.Id_personnel
and Personnel.Name
available for the symposium (not in medical leave or on holiday).
In my example if Symposium_start_date = 2012-10-02
and Symposium_end_date = 2012-10-06
the result must be:
Id_personnel Name
1 John
3 Tom
(as you can see Alice and Charles are on medical leave and Ben on holiday)
Thank you!