分组查询到结果后,组内的数据还想排序
select a.id,a.x from (
select id,count(*) as x from (
select * from message order by id desc limit 1000000
) as msg
group by msg.sender
)as a
where a.x>1
重点:内部查询必须加上limit,这样可以防止mysql的优化,造成order by被忽略。
分组查询到结果后,组内的数据还想排序
select a.id,a.x from (
select id,count(*) as x from (
select * from message order by id desc limit 1000000
) as msg
group by msg.sender
)as a
where a.x>1
重点:内部查询必须加上limit,这样可以防止mysql的优化,造成order by被忽略。