group by 分组
group_concat(符合分组的条件的字段)
group by之后 拿group_concat(截取倒叙最新,加分隔符),再通过subsirng_index截取分隔符的第一个
SUBSTRING_INDEX(GROUP_CONCAT(
DISTINCT d.`json_data`
ORDER BY l.`create_time` DESC
SEPARATOR '|'
), '|', 1) jsonData,
更简单的
获取符合条件的最新数组,作为条件inner join
SELECT
*
FROM
`current` c
INNER JOIN
(SELECT
MAX(d.time) t,
d.`subject` s
FROM
`current` d
WHERE 1 = 1
GROUP BY d.`subject`) d
ON c.`subject` =d.s AND c.`time`=d.t