MySQL Forums
Forum List  »  Newbie

Using date and increment as row id
Posted by: Raymond Jender
Date: June 10, 2021 11:03AM

I am a newbie with mysql.

I am in the process of creating a client request database. I would like to include an id like this: 21060001 where 21 is the year, 06 the month and xxxx is an index that gets incremented with every client request, thus creating a "jobnumber". The jobnumber index will reset to 0000 when the month or year changes. So the table would look something like this:

|jobnumber | Client Name | Client Email | Company Name | Address | etc....
---------------------------------------------------------------------------------------------
21060000 | Joe Blow | joeblow@gmail.com | Joes Buuble Gum, LLC | 1234 56th St. |
---------------------------------------------------------------------------------------------
21060001 | John Jones | johnjones@gmail.com | Jones Construction | 2345 67th St. |
---------------------------------------------------------------------------------------------
21060002 | etc.......
---------------------------------------------------------------------------------------------
21070000 | etc.......
---------------------------------------------------------------------------------------------
22010000 | etc.......
---------------------------------------------------------------------------------------------

Would this be something mySQL can do or do I need a PHP script?

Thanks for your help.

Ray

Options: ReplyQuote


Subject
Written By
Posted
Using date and increment as row id
June 10, 2021 11:03AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.