Prikazi cijelu temu 08.06.2020 08:04
Avko Van mreze
Administrator
Registrovan od:28.05.2014
Lokacija:zagreb


Predmet:Re: SQL upiti
Ja sam uspio za jedan datum:

PreuzmiIzvorni kôd (Text):
  1. SELECT r1.date, e1.id_employees, r1.id_department, s1.id_office, s1.startTime
  2. FROM tbl_schedule as r1
  3. INNER JOIN tbl_calendar AS k1 ON r1.date = k1.date
  4. INNER JOIN tbl_citydepartmentoffice AS s1
  5.     ON (k1.id_cityDepartmentOffice = s1.Id_cityDeparmentOffice AND r1.id_department = s1.id_department)
  6. INNER JOIN tbl_employees AS e1 ON r1.id_employees=e1.id_employees
  7. WHERE r1.date = DATE('2020-06-01')
  8.         AND s1.id_office =(
  9.                                     SELECT s2.id_office
  10.                                     FROM tbl_schedule as r2
  11.                                     INNER JOIN tbl_calendar AS k2 ON r2.date = k2.date
  12.                                     INNER JOIN tbl_citydepartmentoffice AS s2
  13.                                             ON (k2.id_cityDepartmentOffice = s2.Id_cityDeparmentOffice
  14.                                                   AND r2.id_department = s2.id_department)
  15.                                     INNER JOIN tbl_employees AS e2 ON r2.id_employees=e2.id_employees
  16.                                     WHERE r2.id_employees='1001' AND r2.date = DATE('2020-06-01'))

rezultat:

dateid_employeesid_departmentid_officestartTime 
2020-06-01100110105:00:00 
2020-06-011002310111:00:00 
2020-06-011003610117:00:00 

zivot je moja domovina.