Pregunta

So basically I have a table with two fields, 'number' and 'title', and I need a query to select the row with the highest value in 'number', for this i used

SELECT MAX('number') FROM table

Now I need to get the value of 'title' that corresponds to the highest value of 'number'.

How can this be achieved?

¿Fue útil?

Solución

Order by the number in descending order and return only one record with limit

select title
from your_table
order by number desc
limit 1

Otros consejos

select title, number from table where number=(select max(number) from table);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top