I think you better do this on the php side (or in any other language).
But just to give you some idea and as an experiment and example for some unique cases (I hope this can be useful somewhere)
Here is my approach:
http://sqlfiddle.com/#!9/57cc65/1
SELECT r.winner_id, (SELECT MAX(IF(winner_id=r.winner_id,IF(@i IS NULL, @i:=1,@i: =@i +1), IF(loser_id = r.winner_id, @i:=0,0))) FROM Results r1 WHERE r1.winner_id = r.winner_id OR r1.loser_id = r.winner_id GROUP BY IF(winner_id=r.winner_id, winner_id,loser_id)) win_streak FROM ( SELECT winner_id FROM Results GROUP BY winner_id ) r
Now it returns not all identifiers, but only the one who has ever won. Therefore, to make it better, perhaps you have a user table. If so, this will simplify the request. If you do not have a user table, you need union all somehow users who have never won.
Welcome if you have any questions.
source share