教您如何实现MySQL查询最大值字段


  本文标签:MySQL查询最大值

  MySQL查询最大值的方法并不十分复杂,下面就为您介绍MySQL查询最大值的方法,如果您遇到过MySQL查询最大值字段的问题,不妨一看  。

  1. select a.*, b.count from (  
  2. select * from message  
  3. where to_uid=2026 and is_del<2 and from_uid>0  
  4.  
  5. order by mid desc  
  6. )   
  7. as a  
  8. join  
  9. (  
  10. select reply_id,count(*) as count from message  
  11. where reply_id>0  
  12. group by reply_id  
  13. )  
  14. as b  
  15. on (a.reply_id=b.reply_id)  
  16.  
  17. group by a.reply_id  
  18. order by a.mid desc  
  19.  
  20.