私は複数のセクションですべて作業できる従業員のテーブルを持っています。セクションは、日付の予約された後しかし、/ sが、彼らはその日MySQL従業員の利用可能性を問い合わせる
Employee表のために他のセクションに予約することができるためには使用できません従業員
id_resources id_sections EmployeeName Section
28 25 Mark Section Two
28 26 Mark Section Three
28 28 Mark Section Four
28 29 Mark Section Five
28 53 Mark Section Six
28 64 Mark Section Seven
28 74 Mark Section Eight
28 76 Mark Section Nine
29 30 Blair Section One
29 47 Blair Section Two
29 49 Blair Section Three
30 82 Sam Section One
30 25 Sam Section Two
30 28 Sam Section Three
30 29 Sam Section Four
31 18 David Section Eleven
31 19 David Section One
31 22 David Section Two
31 25 David Section Three
その後、私の予約テーブルがです予約
id_resources id_sections startdate enddate
28 25 2016-09-09 2016-09-09
28 26 2016-09-20 2016-09-20
28 28 2016-10-17 2016-10-17
30 82 2016-10-18 2016-10-18
30 25 2016-10-28 2016-10-28
29 30 2016-11-02 2016-11-02
29 47 2016-11-07 2016-11-07
29 49 2016-11-01 2016-11-01
29 58 2017-01-09 2017-01-09
だから私は持っている問題はすべき従業員を取得している:
A.)1つのセクションが1日予約されている場合、すべてのセクションで利用できるわけではありません。
B.)日付範囲が選択され、その範囲の予約がない場合に従業員を表示します。
私は一部B一部を得るが、することはできません。
Select *
FROM employees
LEFT JOIN bookings on employees.id_resources = bookings.id_resources
WHERE
(Select..... and i get lost here
もう一度ご協力いただきありがとうございます。
SELECT employees.*
FROM employees
LEFT OUTER JOIN bookings
ON employees.id_resources = bookings.id_resources
AND (
(startdate BETWEEN $start_range AND $end_range)
OR
(enddate BETWEEN $start_range AND $end_range)
)
WHERE bookings.id_resources IS NULL
クイック説明:
-Lee
なぜid_sectionsの代わりにid_resourcesを使用しているのですか? – FreedomPride