mysql - Auto-increment - automatic reset for each year -
mysql/innodb
in case receipts should counted on yearly basis; 1/2015, 2/2015 ... 556/2015 , on. when next year comes, counter should start 1 again , receipts should counted 1/2016, 2/2016 ...
how define auto_increment field reset on yearly basis?
rcid | rcno | rcyear | ... =====+======+========+==== 200 | 1 | 2015 | 201 | 2 | 2015 | ... | ... | 2015 | 756 | 556 | 2015 | <- last receipt in 2015 757 | 1 | 2016 | <- yearly counter restarted note: rcid standard pk auto incremented field.
this not proper usage of auto_increment. if want special describe, yourself.
myisam has feature (the second column in primary key auto_increment that). innodb preferred these days. way simulate in my blog
Comments
Post a Comment