Predmet:Re: SQL upiti
Ja sam uspio za jedan datum:
PreuzmiIzvorni kôd (Text):SELECT r1.date, e1.id_employees, r1.id_department, s1.id_office, s1.startTime
FROM tbl_schedule as r1
INNER JOIN tbl_calendar AS k1 ON r1.date = k1.date
INNER JOIN tbl_citydepartmentoffice AS s1
ON (k1.id_cityDepartmentOffice = s1.Id_cityDeparmentOffice AND r1.id_department = s1.id_department)
INNER JOIN tbl_employees AS e1 ON r1.id_employees=e1.id_employees
WHERE r1.date = DATE('2020-06-01')
AND s1.id_office =(
SELECT s2.id_office
FROM tbl_schedule as r2
INNER JOIN tbl_calendar AS k2 ON r2.date = k2.date
INNER JOIN tbl_citydepartmentoffice AS s2
ON (k2.id_cityDepartmentOffice = s2.Id_cityDeparmentOffice
AND r2.id_department = s2.id_department)
INNER JOIN tbl_employees AS e2 ON r2.id_employees=e2.id_employees
WHERE r2.id_employees='1001' AND r2.date = DATE('2020-06-01'))
rezultat:
date | id_employees | id_department | id_office | startTime | |
2020-06-01 | 1001 | 10 | 1 | 05:00:00 | |
2020-06-01 | 1002 | 310 | 1 | 11:00:00 | |
2020-06-01 | 1003 | 610 | 1 | 17:00:00 | |
zivot je moja domovina.