hey, just wondering if anyone could help me. i have no idea how to do this so i come to the experts once again lol.
i am trying to add a unique id to a row in mysql database when i insert a new product.
i could add one manually but i would rather let the computer do it for example i am looking for a script that looks at the last id on the above row then add 1 to it so its gives me the id if you see what i mean
thanks
Add a id automatically
Started by Crofty, Aug 30 2006 05:30 AM
5 replies to this topic
#1
Posted 30 August 2006 - 05:30 AM
#2
Posted 30 August 2006 - 06:08 AM
add auto_increment to the specific field.
http://dev.mysql.com/doc/refman/5.0/en/rep...-increment.html
http://dev.mysql.com/doc/refman/5.0/en/rep...-increment.html
#3
Posted 30 August 2006 - 07:53 AM
Just make sure the field type is INT and not TINYINT, common mistake
Edited by .Matt, 30 August 2006 - 09:03 AM.
#4
Posted 30 August 2006 - 08:48 AM
.Matt, on Aug 30 2006, 07:53 AM, said:
Just make sure the field type is tinyint and not int, common mistake 
curious Matt, why is that?
Quote
TINYINT[Length]
1 byte
Range of -128 to 127 or 0 to 255 unsigned.
SMALLINT[Length]
2 bytes
Range of -32,768 to 32,767 or 0 to 65535 unsigned.
MEDIUMINT[Length]
3 bytes
Range of -8,388,608 to 8,388,607 or 0 to 16,777,215 unsigned.
INT[Length]
4 bytes
Range of -2,147,483,648 to 2,147,483,647 or 0 to 4,294,967,295 unsigned.
1 byte
Range of -128 to 127 or 0 to 255 unsigned.
SMALLINT[Length]
2 bytes
Range of -32,768 to 32,767 or 0 to 65535 unsigned.
MEDIUMINT[Length]
3 bytes
Range of -8,388,608 to 8,388,607 or 0 to 16,777,215 unsigned.
INT[Length]
4 bytes
Range of -2,147,483,648 to 2,147,483,647 or 0 to 4,294,967,295 unsigned.
#5
Posted 30 August 2006 - 08:59 AM
lol, ahha i meant INT not TINYINT as TINYINT has a 127 entry limit, which means you will get an error after 127 records.
Thats what i meant above. I blame lack of sleep rofl.
edit: just remembered your pm.
Thats what i meant above. I blame lack of sleep rofl.
edit: just remembered your pm.
Edited by .Matt, 30 August 2006 - 09:02 AM.
#6
Posted 30 August 2006 - 01:32 PM
.Matt, on Aug 30 2006, 08:59 AM, said:
lol, ahha i meant INT not TINYINT as TINYINT has a 127 entry limit, which means you will get an error after 127 records.
Thats what i meant above. I blame lack of sleep rofl.
edit: just remembered your pm.
Thats what i meant above. I blame lack of sleep rofl.
edit: just remembered your pm.
lol. i thought you had an actual answer to that.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
