BiH



#46 11.06.2020-15:34
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,718


Ocjena: Ocjena:100 Subject: Re: SQL upiti
DownloadIzvorni kod (SQL):
  1. SELECT r1.date, e1.id_employees, r1.id_department, s1.id_office, s1.startTime,CONCAT(r1.id_department,'_',s1.id_office,'_',r1.date) AS Uslov
  2. FROM tbl_schedule AS r1
  3. INNER JOIN tbl_calendar AS k1 ON r1.date = k1.date
  4. LEFT JOIN tbl_citydepartmentoffice AS s1 ON (k1.id_cityDepartmentOffice = s1.Id_cityDeparmentOffice AND r1.id_department = s1.id_department)
  5. INNER JOIN tbl_employees AS e1 ON r1.id_employees=e1.id_employees
  6. INNER JOIN (
  7.     SELECT ra1.date, ea1.id_employees, ra1.id_department, sa1.id_office, sa1.startTime
  8.     FROM tbl_schedule AS ra1
  9.     INNER JOIN tbl_calendar AS ka1 ON ra1.date = ka1.date
  10.     LEFT JOIN tbl_citydepartmentoffice AS sa1 ON (ka1.id_cityDepartmentOffice = sa1.Id_cityDeparmentOffice AND ra1.id_department = sa1.id_department)
  11.     INNER JOIN tbl_employees AS ea1 ON ra1.id_employees=ea1.id_employees
  12.     WHERE ea1.id_employees=1001) tUs
  13.     ON CONCAT(s1.id_office,'_',r1.date) = CONCAT(tUs.id_office,'_',tUs.date)
  14. UNION ALL
  15. SELECT r1.date, e1.id_employees, r1.id_department, s1.id_office, s1.startTime,CONCAT(r1.id_department,'_',s1.id_office,'_',r1.date) AS Uslov
  16. FROM tbl_schedule AS r1
  17. INNER JOIN tbl_calendar AS k1 ON r1.date = k1.date
  18. LEFT JOIN tbl_citydepartmentoffice AS s1 ON (k1.id_cityDepartmentOffice = s1.Id_cityDeparmentOffice AND r1.id_department = s1.id_department)
  19. INNER JOIN tbl_employees AS e1 ON r1.id_employees=e1.id_employees
  20. INNER JOIN (
  21.     SELECT ra1.date, ea1.id_employees, ra1.id_department, sa1.id_office, sa1.startTime
  22.     FROM tbl_schedule AS ra1
  23.     INNER JOIN tbl_calendar AS ka1 ON ra1.date = ka1.date
  24.     LEFT JOIN tbl_citydepartmentoffice AS sa1 ON (ka1.id_cityDepartmentOffice = sa1.Id_cityDeparmentOffice AND ra1.id_department = sa1.id_department)
  25.     INNER JOIN tbl_employees AS ea1 ON ra1.id_employees=ea1.id_employees
  26.     WHERE ea1.id_employees=1001) tUs
  27. ON r1.date=tUs.date AND e1.id_employees=tUs.id_employees
  28. WHERE ISNULL(s1.id_office)
  29. ORDER BY date ASC, id_department ASC
↑  ↓

#47 11.06.2020-23:44
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 3,836


Subject: Re: SQL upiti
1. nema 1001 za 1.6.
2. zasto mi u rezultatu daje EDIT, COPY, DELETE kolone? (mozda ovo LINK, greška u phpAdminu, koliko sam razumio)


Život je moja domovina.
Ovaj komentar je mijenjan 1 puta. zadnja izmjena 11.06.2020-23:48 od strane Avko. ↑  ↓

#48 12.06.2020-09:01
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,718


Ocjena: Ocjena:100 Subject: Re: SQL upiti
Ja sam na sql a koi si potvrdio dodao jos jedan sql sa union za ono FD sta nije bilo . Smatram da je problem taj PHP myAdmin koj koristis,Potrazi uzmi neki alat za misajne koda u my sql i vidi sta ces dobiti.
Za pocetak pokreni oba dva sql a bez Union All I pogledaj rezultat.
Evo sta ja dobijam:

Ikona prilozene slike:
1111.png
Tip fajla: Informacije o fajlu: png png
Preuzimanja: 6
Veličina: 51.23 KB
Veličina slike: 916 x 479 Pixels

↑  ↓

#49 12.06.2020-22:08
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 3,836


Subject: Re: SQL upiti
1. sql

DownloadIzvorni kod (Text):
  1. SELECT r1.date, e1.id_employees, r1.id_department, s1.id_office, s1.startTime,CONCAT(r1.id_department,'_',s1.id_office,'_',r1.date) AS Uslov
  2. FROM tbl_schedule AS r1
  3. INNER JOIN tbl_calendar AS k1 ON r1.date = k1.date
  4. LEFT JOIN tbl_citydepartmentoffice AS s1 ON (k1.id_cityDepartmentOffice = s1.Id_cityDeparmentOffice AND r1.id_department = s1.id_department)
  5. INNER JOIN tbl_employees AS e1 ON r1.id_employees=e1.id_employees
  6. INNER JOIN (
  7.     SELECT ra1.date, ea1.id_employees, ra1.id_department, sa1.id_office, sa1.startTime
  8.     FROM tbl_schedule AS ra1
  9.     INNER JOIN tbl_calendar AS ka1 ON ra1.date = ka1.date
  10.     LEFT JOIN tbl_citydepartmentoffice AS sa1 ON (ka1.id_cityDepartmentOffice = sa1.Id_cityDeparmentOffice AND ra1.id_department = sa1.id_department)
  11.     INNER JOIN tbl_employees AS ea1 ON ra1.id_employees=ea1.id_employees
  12.     WHERE ea1.id_employees=1001) tUs
  13.     ON CONCAT(s1.id_office,'_',r1.date) = CONCAT(tUs.id_office,'_',tUs.date)

rezultat:
dateid_employeesid_departmentid_officestartTimeUslov
2020-06-01100110105:00:0010_1_2020-06-01
2020-06-011002310111:00:00310_1_2020-06-01
2020-06-011003610117:00:00610_1_2020-06-01
2020-06-04100130306:00:0030_3_2020-06-04
2020-06-041002330312:00:00330_3_2020-06-04
2020-06-041003630318:00:00630_3_2020-06-04
2020-06-031001330312:00:00330_3_2020-06-03
2020-06-031002630318:00:00630_3_2020-06-03
2020-06-03100930306:00:0030_3_2020-06-03
2020-06-051001620217:30:00620_2_2020-06-05
2020-06-05100820205:30:0020_2_2020-06-05
2020-06-051009320211:30:00320_2_2020-06-05
2020-06-021001630318:00:00630_3_2020-06-02
2020-06-02100830306:00:0030_3_2020-06-02
2020-06-021009330312:00:00330_3_2020-06-02
2020-06-061001320215:00:00320_2_2020-06-06
2020-06-06100920209:00:0020_2_2020-06-06

2.sql
DownloadIzvorni kod (Text):
  1. SELECT r1.date, e1.id_employees, r1.id_department, s1.id_office, s1.startTime,CONCAT(r1.id_department,'_',s1.id_office,'_',r1.date) AS Uslov
  2. FROM tbl_schedule AS r1
  3. INNER JOIN tbl_calendar AS k1 ON r1.date = k1.date
  4. LEFT JOIN tbl_citydepartmentoffice AS s1 ON (k1.id_cityDepartmentOffice = s1.Id_cityDeparmentOffice AND r1.id_department = s1.id_department)
  5. INNER JOIN tbl_employees AS e1 ON r1.id_employees=e1.id_employees
  6. INNER JOIN (
  7.     SELECT ra1.date, ea1.id_employees, ra1.id_department, sa1.id_office, sa1.startTime
  8.     FROM tbl_schedule AS ra1
  9.     INNER JOIN tbl_calendar AS ka1 ON ra1.date = ka1.date
  10.     LEFT JOIN tbl_citydepartmentoffice AS sa1 ON (ka1.id_cityDepartmentOffice = sa1.Id_cityDeparmentOffice AND ra1.id_department = sa1.id_department)
  11.     INNER JOIN tbl_employees AS ea1 ON ra1.id_employees=ea1.id_employees
  12.     WHERE ea1.id_employees=1001) tUs
  13. ON r1.date=tUs.date AND e1.id_employees=tUs.id_employees
  14. WHERE ISNULL(s1.id_office)
  15. ORDER BY date ASC, id_department ASC

dateid_employeesid_departmentid_officestartTimeUslov
2020-06-071001FDNULL    NULL    NULL  


to je to, hvala Gjoreski. Rezultat je ono sto sam trazio.
Potrazit cu rijesenje za union all i prouciti.

hvala jos jednom
Život je moja domovina.
↑  ↓

#50 14.06.2020-11:12
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 3,836


Subject: Re: SQL upiti
evo pokrenuo sam u starom wampserver, tamo mi ne radi php >5.5 i tamo UNION ALL radi.
Evo rezultat:



eto, nemoze sve biti idealno. wampserver nema novi php, a UwWamp ne podrzava UNION ALL.
Tako je to u zivotu
Život je moja domovina.
↑  ↓

#51 14.06.2020-18:59
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,718


Ocjena: Ocjena:100 Subject: Re: SQL upiti
Pokusaj samo UNION bes ALL
↑  ↓

#52 15.06.2020-12:04
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 3,836


Subject: Re: SQL upiti
Citat od Gjoreski:
Pokusaj samo UNION bes ALL

nece, isto kao i sa UNION ALL.
Nema veze. Bitno da smo rijesili problem upita.
Kada izade neka nova verzija UwAmp-a instalirat cu.

hvala
Život je moja domovina.
↑  ↓

Stranice (4): 1, 2, 3, 4


All times are GMT +01:00. Current time: 07.07.2020-10:21.