doushi7819 2015-09-13 18:36
浏览 33
已采纳

使用PHP或MySql从其他人的结果创建一个新的MySql列

I have this situation:

    NAME    |    SURNAME    |    RANK
  JASMINE     VISMITANANDA        4
  JASMINE     VISMITANANDA        6

And I would love to obtain this situation using MySql and / or PHP

NAME    |    SURNAME    |    RANK
JASMINE     VISMITANANDA      4 - 6

There's a way to do it without looping too much with PHP?

  • 写回答

1条回答 默认 最新

  • duanjing9339 2015-09-13 18:40
    关注

    You can use a group by. This might do what you want:

    select name, surname, concat_ws(' - ', min(rank), max(rank)) as rank
    from table t
    group by name, surname;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?