SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast indepthmedia's Avatar
    Join Date
    Apr 2005
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    auto_increment primiary key formatted as 001, 002, etc.

    How do I set an auto_increment primary key to store id values in a 3 digit format like 001, 002, 003, etc.? Simple question, and normally I would just look it up online or something but I don't know what to look up.

    Also, is it possible to store auto_increment primiary key values with letters? For example, ab001, ab002, etc.?

  2. #2
    SitePoint Addict
    Join Date
    Nov 2005
    Location
    Germany
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using
    Code:
    INT( 3 ) UNSIGNED ZEROFILL
    for your key definition.

  3. #3
    SitePoint Enthusiast indepthmedia's Avatar
    Join Date
    Apr 2005
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahhh... thank you.

    Anybody know about this: "Also, is it possible to store auto_increment primiary key values with letters? For example, ab001, ab002, etc.?"

  4. #4
    SitePoint Guru brent5392's Avatar
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No. It must be a number.
    PHP | MySQL | (X)HTML | CSS

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Brent

    Agreed with brent that you can only Increment the number not the alphabets.

    Thankyou

  6. #6
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As an alternative solution, you can just store numeric values in the database. When you extract these values from php simply append the required text to the numbers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •