Page 1 of 1

Value of another field in the row that contains MAX(field)

Posted: Fri Oct 07, 2005 11:31 am
by Bill H
Okay, that subject is clear as mud, but it's the best I could do.

I have a table with two fields: "Seq" which is an int, and "Typ" which is an ENUM('Q','A'). (There's more than those two, but...) I know how to write a query to find out the maximum value for "Seq" but I don't really care about that value. What I want to know is the value of "Typ" in the row that contains that maximum value. Is there a single query to do that?

Posted: Fri Oct 07, 2005 11:59 am
by feyd

Code: Select all

SELECT `Typ` FROM `table` ORDER BY `Seq` DESC LIMIT 1

Posted: Fri Oct 07, 2005 2:33 pm
by Bill H
Duh. I keep forgetting how useful LIMIT is.
Thank you so much