使用场景:为了获取工单的最新的一条数据,按order by再group by的时候获取的最旧的,不是要的效果
故:
select * from ticket_remark
where id in (select SUBSTRING_INDEX(group_concat(id order by `id` desc),',',1) from `ticket_remark` group by ticket_id)
and label = '0101050000'
order by `id` desc
使用场景:为了获取工单的最新的一条数据,按order by再group by的时候获取的最旧的,不是要的效果
故:
select * from ticket_remark
where id in (select SUBSTRING_INDEX(group_concat(id order by `id` desc),',',1) from `ticket_remark` group by ticket_id)
and label = '0101050000'
order by `id` desc