mysql查询最大值max()对应的记录值。

来源:互联网 发布:配置php开发环境win10 编辑:程序博客网 时间:2024/05/29 10:58

群里有人问。。开始以为  max() ,然后分组就可以。。结果试确实不行。。


正确方式如下:


select myid,price,other from test as t   
where  price=(select max(t1.price)  
                  from test as t1  
                  where t.myid = t1.myid  
                  )



0 0