Re: Dealing with auto-increment in MySQL
| From: | Jason Pruim | Date: | Tue, 04 Sep 2007 19:14:29 +0000 |
| Subject: | Re: Dealing with auto-increment in MySQL | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261696@lists.php.net to get a copy of this message | ||
On Sep 4, 2007, at 12:20 PM, brian wrote:
Jason Pruim wrote:I see what you're getting at, but if PHP is controlling a "Record Number" you could have it loop through the results find the gaps and truncate the table to provide a record number. No idea how to do it, just that I'm sure it can be done :)As the person who started the other thread about this ...As one of the people responsible for dragging that thread out ...But after discussing it, I see where my thinking was wrong in how I wanted to achieve it, and also my misunderstanding of the way databases worked. I'm pretty new working with databases, and PHP. HTML and CSS I've done for awhile, just never needed a database or programming language until recently :)Which is why i think it's important to discuss this. Given that yet another thread has already begun on this topic, it seems worthy of dscussion.so to put my 2¢ in on this, I would say to leave alone the auto increment field especially if it's included in an index. If you need a record number, either store it in the database in a separate field as tedd suggested, and leave the main auto increment field alone. OR use PHP (Or your favorite programming language) to add a "Record number" to the display.Except that, should this seperate field be used, as soon as some row in the table is deleted, *that* index column value will *also* suddenly have a gap and you're back to re-ordering. id PLU index 1 foo-324 1 2 foo-894 2 <- delete this row 3 foo-929 3 4 foo-653 4
-- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com japruim@raoset.comOkay I'm done now :)me too, i think brian --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php