Question

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?

Was it helpful?

Solution

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

OTHER TIPS

select title, number from table where number=(select max(number) from table);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top