|
|
|
#1 (permalink) | ||||||||||||
|
Audiophile
|
I have a table with a column called ID which auto increments when i add values but the problem is when I go to delete a row before another row and I try to add another value, I get:
"Error: Duplicate entry '2' for key 1" So is there a way to make that column auto update to "1" if it starts at "2" and if there are values (doesn't go up like 1, 2, 3, 4, etc) missing?
|
||||||||||||
|
|
|
|
#2 (permalink) | |||||||||||||
|
AMD Overclocker
|
I don't think there is. You have your ID row setup like this right:
__________________
My s939 rig build log thread - 4600+ @ 2.8Ghz stable ![]() Aumotocnic "An unfortunate member of the overclock.net insomnia club" Quebec Overclockers - 8019 in 3dMark06s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741 @ 2945Mhz @ 1.45V (YAY! - Not stable, doh!) - http://valid.x86-secret.com/show_oc.php?id=276669
|
|||||||||||||
|
|
|
|
#3 (permalink) | |||||||||||||
|
Database Developer
|
Set it as an Identity field. In MSSQL I know it is Identity(1,1)
__________________
A fan of anything which uses AES, .NET, Relational Databases, RAID arrays, water cooling, HSDPA, GPS, x64 or a BMW engine.
|
|||||||||||||
|
|
|
|
|
#5 (permalink) | ||||||||||||
|
Audiophile
|
Well considering i only have access to phpMyAdmin to work with, how can i do that with only:
Field Type Collation Attributes Null Default Extra Action ID int(3) ----------------------------No--------- auto_increment as options available. Anyone know how to do this, or is this done through a SQL Query or through the php
Last edited by F3t1sh : 01-31-08 at 10:55 PM. |
||||||||||||
|
|
|
|
#6 (permalink) | ||||||||||||
|
Audiophile
|
would my code be something like:
CREATE TABLE room ( ID INT(1,1) NOT NULL AUTO_INCREMENT, ) even then it doesnt work
|
||||||||||||
|
|
|
|
#7 (permalink) | |||||||||||||
|
AMD Overclocker
|
Is it set as the primary key?
__________________
My s939 rig build log thread - 4600+ @ 2.8Ghz stable ![]() Aumotocnic "An unfortunate member of the overclock.net insomnia club" Quebec Overclockers - 8019 in 3dMark06s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741 @ 2945Mhz @ 1.45V (YAY! - Not stable, doh!) - http://valid.x86-secret.com/show_oc.php?id=276669
|
|||||||||||||
|
|
|
|
#8 (permalink) | ||||||||||||
|
Database Developer
|
Quote:
Code:
CREATE TABLE room ( ID identity INT(1,1) NOT NULL AUTO_INCREMENT, )
|
||||||||||||
|
|
|
|
|
#9 (permalink) | ||||||||||||
|
Audiophile
|
Yes it is and still doesn't work
|
||||||||||||
|
|
|
|
#10 (permalink) | |||||||||||||
|
Audiophile
|
Quote:
Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identity INT(1,1) NOT NULL AUTO_INCREMENT, )' at line 3 (0 ms taken) I guess my real problem is reseting the ID row and making it auto number itself again when i delete something.
|
|||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|