Solved

mysql auto increment  help needed

Posted on 2011-03-06
3
558 Views
Last Modified: 2012-05-11
Hi

How to set a auto increment value starting like  00001 instead of 1 ?


Thanks
0
Comment
Question by:3xtr3m3d
3 Comments
 
LVL 1

Accepted Solution

by:
geff_chang earned 167 total points
ID: 35046178
The autoincrement value is a number (an integer).
So, leading 0s does not mean anything.

If you want to have leading 0s displayed in your client / program,
you need to manually format the data to be displayed with leading 0s.
It shouldn't be difficult to do.
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 167 total points
ID: 35046200
I confirm the above statement, leading 0000 are formatting, not data.
0
 
LVL 11

Assisted Solution

by:Ovid Burke
Ovid Burke earned 166 total points
ID: 35046219
You can specify zerofill:

ALTER TABLE `table_name`
MODIFY COLUMN `column_name`  int(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT FIRST ;

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question