Selecting the highest value
Jan Eden <[email protected]>
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <r02010500-1039-FFCA38C4FF5711D990D5000A959B4026@[10.149.23.98]> |
Hi,
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?
Example:
my ($last_pic_id) = $dbh->selectrow_array("SELECT picture_id FROM pictures WHERE gallery_id = $self->{fields}->{gallery_id}->{value} AND position = XXXX");
I need the picture being at the last position within the gallery. Can I do that? I tried a workaround using the rowcount (via COUNT(*)), but that is a bit unstable in case the position list has gaps.
Thanks,
Jan
--
Any sufficiently advanced technology is insufficiently documented.
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/[email protected]