1

I have a product purchasing system and I want to have a unique identifier with the format PID*n*, where n is an autoincrementing number.

  • PID00001
  • PID00002
  • PID00003

How can this be done with VB6 and MySQL?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Handy Manny
  • 388
  • 1
  • 4
  • 20
  • could you ask what you need specifically? – Nick Andriopoulos Mar 13 '13 at 13:36
  • I want a code to achieve this. I've searched about COncAT but i don't know how to use this. – Handy Manny Mar 13 '13 at 13:38
  • Since a PK should never be exposed by any UI anyway why would you care whether they are integer values, GUIDs, or anything else? – Bob77 Mar 13 '13 at 15:01
  • You don't want the code to achieve this. If you do want it, you're using a relational database in entirely wrong way and you require reading up on what primary keys are, what they do and especially how they help MySQL maintain performance. – N.B. Mar 13 '13 at 15:03

1 Answers1

2

This is not possible. You can either prefix and pad your auto-increment integer or have two separate columns that are combined by a trigger. See this answer for a better explanation.

Community
  • 1
  • 1
Kermit
  • 33,827
  • 13
  • 85
  • 121