我想通过一个查询获得每个驱动程序的最新位置
select d.id, d.names, d.phone, d.vehicle, d.platenumber, dp.lat, dp.lng, MAX(dp.added_date) as added_date
from drivers d,
(SELECT * FROM driver_positions ORDER BY added_date DESC) as dp
where d.id = dp.driver_id and d.status = "1" and DATE(added_date) = DATE(NOW())
GROUP BY d.id order by dp.added_date ASC
有效,但对于1个驱动程序仅返回一个结果,但未按预期列表返回:
是否可以通过1个查询获得正确的信息,否则我将不得不循环。
谢谢您的帮助!