Problem of storing employee id in mysql?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KanikaSen
    New Member
    • Apr 2010
    • 2

    Problem of storing employee id in mysql?

    Hii everyone
    I m new to this forum.
    I have a table emp having employee details I want to make e_id as primary key auto-incremented . but I don't want to store ids as 1,2,3.... I want to store them as e1,e2,e3... I know it is possible by composite primary key(e + 1) but don't know how ?and Will composite key work with Mysql?
    Person who knows the answer plz solve my problem.
    thanks in advance
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    What does the "e" stand for? If e is for employee then can't you just assume that e is always at the front of any ID number and just add it in when selecting data from the database? Will it ever be anything other than 'e'?

    Comment

    • KanikaSen
      New Member
      • Apr 2010
      • 2

      #3
      Originally posted by RedSon
      What does the "e" stand for? If e is for employee then can't you just assume that e is always at the front of any ID number and just add it in when selecting data from the database? Will it ever be anything other than 'e'?
      Thanx RedSon for your reply I was also thinking for same but I thought if someone knew about storing it with e.
      Once again thanks a lot for your response

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Hey.

        If you want the key auto_incremente d, it needs to be a number. You can not store it with the letter without losing the auto incrementation.

        You can of course create a composite primary key, but it won't really affect the way the data is displayed. Even if you had two columns, one with the auto incremented number and one with the letter, and you created a composite key out of those two columns, you would still need to concatenate them if you wanted to display them together.

        If the "e" is always going to be present, like RedSon pointed out, then you could just as well assume it is always going to be there and add it on the way out.

        Perhaps if you explained why you need the "e" to be there, we could offer some alternatives.

        Comment

        Working...