RE: [PHP] Mysql Rows
| From: | jblanchard at pocket dot com | Date: | Mon, 06 Mar 2006 13:22:13 +0000 |
| Subject: | RE: [PHP] Mysql Rows | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231507@lists.php.net to get a copy of this message | ||
[snip]
>You must have a column that is sequential in some way. An
>auto-incremented column, timestamp, or some other device that will
allow
>you to step through regardless of gaps in sequence. If you do not have
>such a column then you could add one.
You see, now that's the problem. If you have a field that has
auto-increment and then delete a record, auto-increment does not go
back and fill up the gaps.
As such, if you don't renumber, then the only thing left is to use a
timestamp, I guess.
[/snip]
No, if you have gaps you can still step through sequentially, like 14,
15, 18, 19, 20...
[snip]
>The simplest example (most recent to oldest):
>
>select * from table order by datefield desc;
>
>
>To get them in the order they were entered:
>
>select * from table order by id asc;
>
>
>To get them in reverse order:
>
>select * from table order by id desc;
Which I could be used in such a way that you also provide a counter
outside of mysql to show the user a number as they step through the
records. However, the next time they want to review record xxx, it
may not be in the same position because of deletions.
[/snip]
But if you never change the record number it will always have the same
record number. If someone searches for a particular record and it is not
there it has been deleted. Renumbering makes this far worse, because if
I am searching for record xxx and the table has been renumbered it may
now be record yy....I'd have no way of knowing.