Posted By
|
Message
|
Pete Nattress Cheesy Bits img src/uploads/sccheesegif
Registered 23/09/2002
Points 4811
|
15th December, 2003 at 15:49:55 -
hmmm, i've just started learning PHP/MySql and i have a small quibble: specefically, it's with the mysql part.
i have a value in a table called "id"... this is set to primary, index and "auto_increment". obviously, this is my table's primary key, and my question is this: if a row is deleted, is there anything i can do to make the database use the deleted row's id number instead of moving up to the next one. argh, that's worded horribly, lemme try an example:
1
2
3
4 <<< deleted
5
so instead of the next record making the table go:
1
2
3
5
6 (new data)
it goes
1
2
3
4 (new data)
5
is there an easy way to do this or will i have to write a function in PHP? thanks.
www.thenatflap.co.uk
|
ShadowCaster Possibly Insane
Registered 02/01/2002
Points 2203
|
15th December, 2003 at 16:17:41 -
No, the auto_increment keyword always remembers the last number to be used and creates the new value based on that (it wouldnt be incrementing, otherwise ).
Plus you can get into trouble doing that if, for example, you have another table which relies on that ID (i.e. a foreign key), where the indexes no longer link up.
Mike
"Now I guess we're... 'Path-E-Tech Management'" -Dilbert
|
Pete Nattress Cheesy Bits img src/uploads/sccheesegif
Registered 23/09/2002
Points 4811
|
15th December, 2003 at 16:21:07 -
ok, cheers mike
www.thenatflap.co.uk
|
Kris Possibly Insane
Registered 17/05/2002
Points 2017
|
16th December, 2003 at 10:16:07 -
yeah, that's annoying
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
|
|
|