I have a MySQL database with a structure like this…
Site has many Sensors
Sensors has many SensorReadings
I want to get all Sensors for a Site and the last 5 SensorReadings for all those Sensors. I suspect I’m going to have to do something with a stored procedure and temporary tables (if they even exist in MySQL.
Possibly Something like…
Please give your actual table structure(s) in your question.