SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    ireland
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I make the primary key alphanumeric !

    Hi

    Want I want to do is create a table with a primary key that
    will increment numbers with a letter code before it.

    For example FG01
    FG02
    FG03

    Is it possible to do this with mysql, I undertand that the primary key value is usually a integer so it might not be possible to do this.But I have seen it done on other sites so it must be possible.

    Could anyone help.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    the primary key can certainly be of that style but you will have to increment it yourself

    if you want to use an auto_increment, you can achieve a similar result by appending the auto_increment value to a constant every time you want to display the key, but this is not recommended, and you should not need to display your key in the first place
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist ghurtado's Avatar
    Join Date
    Sep 2003
    Location
    Wixom, Michigan
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you post the same question twice?
    Garcia


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
  •