create table invoices(
year int not null
,invoice_number int not null auto_increment
,primary key(year, invoice_number)
);
insert into invoices(year) values(2009);
insert into invoices(year) values(2009);
insert into invoices(year) values(2009);
insert into invoices(year) values(2010);
insert into invoices(year) values(2010);
insert into invoices(year) values(2010);
select *
from invoices;
+------+----------------+
| year | invoice_number |
+------+----------------+
| 2009 | 1 |
| 2009 | 2 |
| 2009 | 3 |
| 2010 | 1 |
| 2010 | 2 |
| 2010 | 3 |
Invoice should be auto generated from every year of 1 april I have created such tables but it will generate from 1 jan , I want to start from 1 april