NYCPHP Meetup

NYPHP.org

[nycphp-talk] primary key alphanumerical

John Lacey jlacey at att.net
Thu Dec 9 16:54:17 EST 2004


jaime bermudez wrote:
> Hi there,
> Is there any way to make a Primary Key that is a
> combination of letters and numbers. I have an
> application form that collects teachers information,
> then every teacher should submit their school
> principal and their school supervisor, the problem is
> that each (PK) is just a consecutive number.
> Therefore, each application contains 3 diferent
> numbers like 001 (for the teacher) 002 (for the
> principal) and 003 (for the supervisor) this gets
> confusing when I try to separate them to transfer from
> MySQL into an Access database. It would be ideal if
> they are something like that : TEA001, PRI001, SUP001,
> etc...
> 

A primary key, or any key, can be comprised of more than one field (and 
they don't have to be contiguous).  So, you can have an auto_increment 
field (fld1) that bumps the numbers and another field (fld2) that 
contains "letters".  The primary key is then keyname (fld1, fld2).

something along those lines should work for you.

HTH,
John




More information about the talk mailing list