devicedata(设备数据表)
需求:查询出各个设备的最新数据。
SELECT
*
FROM
devicedata
WHERE
id IN (
SELECT
SUBSTRING_INDEX(
GROUP_CONCAT(id ORDER BY `times` DESC),
',',
1
)
FROM
devicedata
GROUP BY
deviceid
)
结果:
devicedata(设备数据表)
需求:查询出各个设备的最新数据。
SELECT
*
FROM
devicedata
WHERE
id IN (
SELECT
SUBSTRING_INDEX(
GROUP_CONCAT(id ORDER BY `times` DESC),
',',
1
)
FROM
devicedata
GROUP BY
deviceid
)
结果: