RE: [PHP] Resetting ID
| From: | John Holmes | Date: | Tue, 30 Jul 2002 12:22:55 +0000 |
| Subject: | RE: [PHP] Resetting ID | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110341@lists.php.net to get a copy of this message | ||
> I have a table, with 4 columns. One of the column is
> ID, a Primary Key, which has Auto_Increment set on it.
>
>
> Now i have a lot of rows deleted and a lot of
> duplicate rows that will be deleted, and all sorts of
> stuff happening in the table.. the result is, that the
> IDs have become inconsistent.
>
> What you get is something like
> 5,6,9,10,25,32,33 .. and so on. With many IDs missing
> etc.
>
> What i want to do is delete the entire IDs and
> generate them again so that they are in one single
> order like 1,2,3,4,5... .like this.
>
> And so that any new entry in the table gets the ID
> accordingly. How can i do this?
Who cares if your IDs aren't sequential?? All these IDs are for is to
provide a unique identifier for each row. That's it. If the holes are
causing a problem in your scripts, then you are using this column
incorrectly. My guess is that you'd want to read up on the COUNT() or
LIMIT functions in MySQL...
---John Holmes...