viz gna, jen muzes narazit na problem, ze oracle a mysql pisou sql dotazy trochu jinak
tab measure - id_measure, id_device, text, datum
tab device - id_device, text
tab kalibrace - id_kalibrace, id_device, text, datum
SELECT a.id_measure, a.text, a.id_device, b.text, c.text, c.datum
FROM measure a
JOIN LEFT device b ON b.id_device = a.id_device
JOIN LEFT kalibrace c ON c.id_device = a.id_device
S tou kalibraci tak uplne nerozumim. Logicky musis pouzit kalibraci takovou, ktera odpovida datumu mereni.
Jakoze, kdyz mas v tabulce kalibraci 5 kalibraci za rok a zajima te mesic unor mereni, tak by tam mela byt kalibrace, ktera tomu odpovida. Pokud v pulce unora zmenis kalibraci a zobrazujes mereni za uor, melo by se to tam projevit.
Jakoze to pridat jako sloupec, ktery je vybiran pres vnoreny SELECT. A nebo prestavet ten prvni dotaz na grupovani a misto LEFT JOIN pro kalibrace pouzit JOIN.
SELECT ... ,
(SELECT MAX(e.datum), e.id_device
FROM kalibrace e
LEFT JOIN mereni f ON f.id_device = e.id_device
WHERE e.datum<c.datum
GROUP BY f.id_device
LIMIT 1) AS datum_kalibrace -- sloupec musis pojmenovat
...