how to create AUTO increment ID number compose of year and number, example: "2012-0001" it will auto_increment to "2012-0002" if i input another data.
Thank You!
how to create AUTO increment ID number compose of year and number, example: "2012-0001" it will auto_increment to "2012-0002" if i input another data.
Thank You!
you're going to have to write a program to do that. Strawberry's solution shows you what needs to be done on the SQL side, but you have to write your interface (non-sql) to break apart the input, so that when the user inputs 2012-0001, the query string says something like "WHERE year=2012 AND id=0001"
if you're asking if you can have a column in your table that can have a hyphen in it yet auto-increment, the answer is no.
Using MyISAM, you can do this...
-- a moment's quiet contemplation for the poor index
...and taking it one step further (coz I figured it was time I knew how to use prepared statements inside sprocs)...