How can I generate alphanumeric unique id, 10 character long, AZ(no lower case), 0-9 only.
I have four (4) tables.
Tables
-
hmo
-
company
-
patient
-
patient_dependent
hmo table
create table
(
hmo_id int auto_increment primary key,
hmo_name varchar(50) not null,
unique_id varchar(10) not null
);
How can I generate 2 digit unique id for the field unique_id.
It should take this format"
A1…A9
.
.
.
.Z1…Z9
When that is exhausted , it takes
AB…AZ
.
.
.
ZA…ZZ
It does the same thing for company table
company table
create table
(
company_id int auto_increment primary key,
hmo_id int not null,
company_name varchar(50) not null,
unique_id varchar(10) not null
);
Now for patient table it needs to generate alphanumeric unique id, 10 character long, AZ(no lower case), 0-9 only.
company table
create table
(
patient_id int auto_increment primary key,
hmo_id int not null,
company_id int not null,
patient_name varchar(50) not null,
unique_id varchar(10) not null
);
Now for the patient table,
it will take the first two digits from the related hmo_id: for example A1,
the next two digits from related company_id : foor example F3,
THE NEXT FIVE DIGITS will be five zero: 00000,
Then the last digit will be based on number of dependants in the dependant table. If it has three dependants,
it will be
000001
000002
000003
So the overall unique id will be something like:
A1F3000000
Please help me out