There is a table (History_locations)
It is necessary to display the current id_location of the machines. I.e
id_rolling_car | id_location
1 | one
2 | 2
3 | one
I think something like this:
SELECT DISTINCT id_rolling_car as id_car, (SELECT HL.id_location FROM History_locations as HL WHERE HL.id_rolling_car = id_car ORDER bY HL.date DESC LIMIT 1) as id_location FROM History_locations 
SELECT id_rolling_car, max(id_location) as id_location FROMhistory_locations` group by id_rolling_car` - Vanya Avchyan