[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] wrote:
>
> Hello,
>
> I need the last entry of a table.
>
> This code interates through a list but how can I get the last
> element ?
How do you define the last entry? Is it the one with the highest/lowest
value in a certain column? The one that was added to the table most
recently? The one that comes out last when the entire table is selected
unsorted?
> my $dbh = DBI->connect("dbi:mysql:$DB", $USER, $PASS) || print
> "MySQL: can't connect to database.";
>
> my $sth = $dbh-> prepare("SELECT message_id FROM $mail_folder_dbi");
>
> $sth -> execute();
>
> my $last_mID;
>
> while ( @row_ary = $sth->fetchrow_array ) {
> print "@row_ary \n";
> }
Perhaps SELECT MAX(message_id) would do what you want in this case.
Ronald