3 messages in com.mysql.lists.perlRe: Selecting the highest value
FromSent OnAttachments
Jan Eden28 Jul 2005 04:08 
Jochen Wiedmann28 Jul 2005 04:24 
Jan Eden28 Jul 2005 04:34 
Subject:Re: Selecting the highest value
From:Jan Eden (lis@janeden.org)
Date:07/28/2005 04:34:44 AM
List:com.mysql.lists.perl

Jochen Wiedmann wrote on 28.07.2005:

On 7/28/05, Jan Eden <lis@janeden.org> wrote:

this must be quite simple, but I have no clue how to do it: Can I select the

row where a certain column has the highest table of all rows satisfying another where condition?

position = MAX(position)

might do the trick. Dunno, which version of MySQL supports it, but the latest should do.

I feared that it would be that simple. Doh!

BTW, the manual says you need a subselect as of MySQL 4.1

SELECT id FROM table WHERE position = (SELECT MAX(position) FROM table);

In older version, you first need to do a select for the MAX value, then a second
one for the row.

Thanks,

Jan