Getting the right data from the database is a tough one, so maybe someone is able to help me out.
I have three tables:
Code: Select all
Devices DeviceDataOregonTempHum
- Id ---------> - DevId
- DevType | - DevTemp
| - DevHum
| - DevUpd
|
| DeviceLocation
|-> - Id
- Description
The following query nearly does what it needs to do. However: For every device in table <i>Devices</i> it displays all records from table <i>DeviceData</i> instead of only the last entry:
Code: Select all
SELECT t1.Id, t2.DevTemp, t2.DevHum, t2.DevUpd, t3.DevLoc
FROM Devices AS t1
JOIN DeviceDataOregonTempHum AS t2
ON (t2.DevId = t1.Id)
JOIN DeviceLocation AS t3
ON (t3.Id = t1.DevLoc)
WHERE (t1.DevType = '1');
Code: Select all
| 39 | 19.4 | 55 | 2009-04-12 08:00:06 | Werkkamer |
| 39 | 19.4 | 55 | 2009-04-12 09:00:06 | Werkkamer |
| 39 | 19.9 | 57 | 2009-04-12 10:00:05 | Werkkamer |
+----+---------+--------+---------------------+-----------------+
1329 rows in set (0.00 sec)
Is there anyone out there who knows the solution?