MySQL查询最大值的方法并不十分复杂,下面就为您介绍MySQL查询最大值的方法,如果您遇到过MySQL查询最大值字段的问题,不妨一看。
- select a.*, b.count from (
- select * from message
- where to_uid=2026 and is_del<2 and from_uid>0
- order by mid desc
- )
- as a
- join
- (
- select reply_id,count(*) as count from message
- where reply_id>0
- group by reply_id
- )
- as b
- on (a.reply_id=b.reply_id)
- group by a.reply_id
- order by a.mid desc
【编辑推荐】