|
-
Mar 10th, 2006, 11:41 PM
#1
Thread Starter
Frenzied Member
autoincrement PK
Is there a way to autoincrement the primary key (ID) as many digits as opposed to single digit (1, 2, 3)?
-
Mar 11th, 2006, 07:45 AM
#2
Re: autoincrement PK
 Originally Posted by vbbit
Is there a way to autoincrement the primary key (ID) as many digits as opposed to single digit (1, 2, 3)?
Not from MySQL its self but you can set the field value directly form a PHP MySQL query 
Cheers,
Ryan Jones
-
Mar 11th, 2006, 04:06 PM
#3
Re: autoincrement PK
Are you using MySql 5? If so, you can do it using a trigger.
-
Mar 11th, 2006, 05:06 PM
#4
Thread Starter
Frenzied Member
Re: autoincrement PK
Could you provide a sample code? I mean just that section. and i don't know what version of mysql is
-
Mar 11th, 2006, 05:33 PM
#5
Re: autoincrement PK
Mysql Query:
-
Mar 11th, 2006, 05:36 PM
#6
Thread Starter
Frenzied Member
Re: autoincrement PK
It is 4.1.14-Max-log
-
Mar 11th, 2006, 06:09 PM
#7
Re: autoincrement PK
Make your Primary key an integer without auto_increment and bfore inserting the record calulate the next vlaue, finds the largest value:
Code:
// finde the largest id
SELECT MAX(id) FROM table;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|