Home  >  Q&A  >  body text

mysql - 如何查询一张表中各个用户优先级最高的模板

例如:表
user temp rank
u1 a 2
u1 b 0.5
u1 c 3
u2 aa 1.7
u2 cc 3
u3 dd 2
我希望拿到u1,b

     u2,aa
伊谢尔伦伊谢尔伦2742 days ago634

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 15:30:12

    Suppose your table name is test:

    select a.user, a.temp from test a left join test b on a.user = b.user and a.rank > b.rank where b.rank is NULL;

    reply
    0
  • 阿神

    阿神2017-04-17 15:30:12

    The one upstairs is the correct answer.

    reply
    0
  • Cancelreply