I’m trying to make a high score list in a MySQL database, just 3 columns: id, name, and score. The table is called Highscores. I tried using this code:
DELETE FROM Highscores WHERE
Score = (SELECT min(Score) FROM Highscores)
AND (SELECT count(*) FROM Highscores) > 10;
But it gives this error:
#1093 - You can't specify target table 'Highscores' for update in FROM clause
How can I delete the row with the lowest value, only if there are more than 10 rows? There could possibly be more than one row with the lowest value, but I only want one to be deleted.
Another approach to keep only 10 greatest scores