Re: Selecting the highest value

Jan Eden <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <r02010500-1039-A614B24AFF5B11D990D5000A959B4026@[10.149.23.98]>
Jochen Wiedmann wrote on 28.07.2005:

>On 7/28/05, Jan Eden <[email protected]> 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
-- 
Any sufficiently advanced technology is indistinguishable from a Perl script. - Programming Perl

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.