Thanks for that BB. How large was the test table (rows and cols)?
Did you test the alternative expressions by conducting a number of queries (to note the impact of any caching)? Did putting an index on age have any impact? (I would expect ORDER BY to improve) Please advise, =dn ----- Original Message ----- From: "Butch Bean" <[EMAIL PROTECTED]> To: "DL Neil" <[EMAIL PROTECTED]>; "Richard Morton" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: 25 January 2002 20:03 Subject: RE: Selecting the row with largest number in a column > The fastest way I found would be: > > SELECT MAX(age) FROM contacts > > good luck > bb > > -----Original Message----- > From: DL Neil [mailto:[EMAIL PROTECTED]] > Sent: Saturday, January 26, 2002 12:14 PM > To: Richard Morton; [EMAIL PROTECTED] > Subject: Re: Selecting the row with largest number in a column > > > Hello Richard, > > > > I have a simple query, and a problem countless people must have had, I > just > > cannot work it out at the moment, I am new to MySQL; I hope you can help. > > > > My current statement looking at the manual. > > SELECT * FROM contacts WHERE age=MAX(age); > > > > I started with: > > mysql> select * from contacts where age=(select MAX(age) from contacts); > > > > > > In escence I am trying to ascertain the details of the person who is > oldest. > > > > Any suggestions.? > > > Use the ORDER BY clause to show the table's records in inverted age order, > then require only the first row: > > SELECT * > FROM contacts > ORDER BY age DESC > LIMIT 1 > > Regards, > =dn > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail ><[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php