By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE Highscores (level int, player_id int, score int);
INSERT INTO Highscores VALUES (1, 9, 100), (1, 2, 100), (1, 3, 200), (1, 4, 250), (1, 0, 0);
SELECT * FROM Highscores
level | player_id | score |
---|---|---|
1 | 9 | 100 |
1 | 2 | 100 |
1 | 3 | 200 |
1 | 4 | 250 |
1 | 0 | 0 |
(SELECT player_id
FROM Highscores
ORDER BY score ASC, player_id ASC LIMIT 1)
player_id |
---|
0 |
UPDATE Highscores
INNER JOIN
(SELECT player_id
FROM Highscores
ORDER BY score ASC, player_id ASC LIMIT 1) rpid
ON Highscores.player_id = rpid.player_id
SET Highscores.player_id = 6, Highscores.score = 300
SELECT * FROM Highscores
level | player_id | score |
---|---|---|
1 | 9 | 100 |
1 | 2 | 100 |
1 | 3 | 200 |
1 | 4 | 250 |
1 | 6 | 300 |