how to generate invoice number such as below :
Invoice Number = MC1200001
MC : Company name
12 : current year (Flexibel)
00001 : auto increment (Flexibel - auto increment and will reset to 00001 again if year is 2013)
expected result :
current year 2012 :
MC1200001
MC1200002
MC1200003
.....
year 2013
MC1300001
MC1300002
MC1300003
.....
Need your idea or solution for this problem.
Thanks.
You could use three columns to express the different parts of the number and use a view or simple CONCAT expression to grab the entire number per invoice.
Then to get a new number, you’d insert a record using a function that would return the actual row id or concatenated number.
I’d do something like this: (leaving the leading zero’s out for brevity)
You can run this as a script against your mysql test database and see the following output: