I have written an invoice module for our reservation system.
So when I create a new invoice, I automatically generate a primary key through MySQL.
However for th
You should use a procedure or a trigger. The particular query that builds your newInvoiceId should be something like this:
SELECT CONCAT(YEAR(now()),count(*)+1) as newInvoiceId
FROM table
WHERE InvoiceId like CONCAT(YEAR(now()),'%');
The only part where i'm not 100% confident is the CONCAT(YEAR(now()),'%')