There are 2 tables:
Table temperature_now:
machine_id | temperature
------------------------
1 | 15
2 | 20
3 | 13
Table temperature_history:
change_id | machine_id | temperature | controller
-------------------------------------------------
1 1 6 Carl
2 2 9 Steve
3 1 7 John
4 1 15 Peter
5 2 20 Peter
6 3 13 Martin
temperature_now.machine_id = temperature_history.machine_id
change_id is auto_increment
I need to get the last change of temperature at each machine:
machine_id | temperature_now | temperature_before | controller
--------------------------------------------------------------
1 15 7 John
2 20 9 Steve
Thanks for your help.