I have a two player game which stores scores in a table.
I want to select high scores from the table, this is my current code:
SELECT * FROM games
ORDER BY GREATEST(player1Score,player2Score) DESC
LIMIT 10
The problem is it only returns one instance of each row, even if for example the lower of the two scores in row 1 warrants inclusion in the top 10.
Use
UNION ALL:Also, don’t use
SELECT *. List the columns explicitly.