In a Mysql table
id valor
1 5
2 15
3 7
I want to get the value of the "id" that has the highest value in the value field. I want it to return the value 2 in this case.
In a Mysql table
id valor
1 5
2 15
3 7
I want to get the value of the "id" that has the highest value in the value field. I want it to return the value 2 in this case.
Sort the result by the DESC value and limit to 1:
SELECT
id
FROM tabela
ORDER BY valor DESC
LIMIT 1;