I have a table with device ID and the date and time of the last update, I'm trying to make a MySQL query to get the last seen update of each device on the table, but when I execute my query, I'm getting the following error:
Subquery returns more than 1 row.
Below is the query that I'm using on my PHP code.
SELECT log_device_dt_lastupdate FROM tb_log_device
WHERE device_id=(SELECT DISTINCT(device_id)
FROM tb_log_device) ORDER BY log_device_dt_lastupdate
DESC LIMIT 1
If I use GROUP_CONCAT
I just get the information from one device.
I don't want to use two queries to get this info from the table, is it possible to have it? Maybe by making a JOIN
?
Thanks.