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?

有帮助吗?

解决方案

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

其他提示

select title, number from table where number=(select max(number) from table);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top