I have a table employee where EmployeeID field is set as primary key. How can I create a custom auto increment for my EmployeeID for example:
EmployeeID
SDD00001
SDD00002
SDD00003
Thus when new records are inserted it will automatically increment just like in the example.
Any idea on how can this be done. Thanks
help regarding auto increment
Moderator: General Moderators
-
greedyisg00d
- Forum Commoner
- Posts: 42
- Joined: Thu Feb 12, 2009 2:48 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: help regarding auto increment
autoincrement fields are only integer. You could produce your ID with
You could also do this kind of thing in SQL to fetch an Employee ID based on an autoincrement integer.
Code: Select all
$EmployeeID = 'SDD' . str_pad($id, 5, '0', STR_PAD_LEFT);
$EmployeeID = sprintf('SDD%05u', $id);(#10850)