I am new to MySQL coming from Oracle. I have a requirement to create a table with the primary key in one column but with the following format.
X-A
letter stating the country of origin e.g. S
for Spain, Z
for Zimbabwe e.tc (we have five countries of origins only)
YYYYMMDD
- Date in that format,
9999
- 4 digit office code.
9999999
- 7 right padded sequence number from a sequence in Oracle (auto increment in MySQL)
This gives me a primary key like Z2010013150110000001
as the primary key.
My question is how do I generate the part of 9999999
in MySQL. In Oracle it would have been
select 'Z'||to_char(sysdate, 'YYYYMMDD')|| 5011||cust_id.nextval from dual;