I’m trying to fetch results from 2 different tables like these:
|TEMPERATURETAB|
TIMESTAMP | TEMPERATURE |
---|---|
Time1 | ValueT1 |
Time2 | ValueT2 |
|HUMIDITYTAB|
TIMESTAMP | HUMIDITY |
---|---|
Time3 | ValueH1 |
Time4 | ValueH2 |
There’s no connection between tables,Timestamp are different, so I don’t think I should use JOIN
I tried to use UNION (since I don’t need Timestamp from Humidity tables I would have deleted when I would have fetched it in php)
SELECT Timestamp as ‘Time’, Temperature as ‘Temp’ FROM Temperaturetab WHERE Timestamp BETWEEN ‘[some timestamp]’ AND ‘[some other timestamp]’ UNION SELECT SELECT Timestamp as ‘TimeB’, Humidity as ‘Hum’ FROM Humiditytab WHERE Timestamp BETWEEN ‘[some timestamp]’ AND ‘[some other timestamp]’
It only returns
Time and Temp