Generating Custom Auto Generated ID

Hello,

Can anyone give show a simple tutorial (step-by-step) to generate custom customer_id in a database table? For example, I have a table named Customer and would like to generate customer_id like the following example:

Table structure:
customer_id (auto-increment), fullname, address, contact, email

Example of customer_id as: 2011-AB001, 2011-CA001, 2012-DA001, 2005-FR001
20 as current year, 11 as current month, AB / CA / DA / FR as first 2 characters of customer name and 001 as increment number.

Regards,
Josh

A field auto-increment only accept numbers. so you need create other field for that.
for ex: customer_code varchar(16)
and you need have a table for yours autoincrements for each 2 characters.

1 Like

New version coming soon — check out what's new in Scriptcase 9.12! New version coming soon — check out what's new in Scriptcase 9.12!