faqts : Computers : Databases : MySQL : Language and Syntax : Queries : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 18 people (44%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How can I get the row with the highest value of a field?

Jun 1st, 2000 05:19
Chas Haynes, Nathan Wallace, Richard Lynch


There should be a Max() function.

You can also use "order by desc" to get them in descending order.

Might want to do a quick run-through of a MySQL tutorial.

--

the statement would look something like this:

SELECT max($fieldname) FROM $db_table;

where $fieldname is the field you're trying to get the highest value 
from, and $db_table is the database table.

Note that this will return the single value of that field only.