in reply to Re: Re: mysql auto_incremented id
in thread mysql auto_incremented id
How do you deal with first and last image then?
I insist on my belief that a primary key should be doing only one task, i.e. identifying the record uniquely. If you need a display id, you have two choices:
SELECT @count := @count+1 as sequence, id, name, filename from mytable
Now your @results have a counter that you can use for displaying purposes.my $query = "SELECT id, name, filename from mytable"; my $sth=$dbh->prepare($query); $sth->execute(); my @results; my $count =0; while (my $row = $sth->fetchrow_arrayref) { push @results, [ $count++ , @$row ] }
|
|---|