Re: Dealing with auto-increment in MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Pruim wrote:

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

Okay 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux