Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8139179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:44:21+00:00 2026-06-06T11:44:21+00:00

Scenario: WAMP server, InnoDB Table, auto-increment Unique ID field [ INT(10) ], 100+ concurrent

  • 0

Scenario: WAMP server, InnoDB Table, auto-increment Unique ID field [INT(10)], 100+ concurrent SQL requests. VB.Net should also be used if needed.

My database has an auto-increment field wich is used to generate a unique ticket/protocol number for each new information stored (service order).

The issue is that this number must be reseted each year. I.e. it starts at 000001/12 on 01/01/2012 00:00:00 up to maximum 999999/12 and then at 01/01/2013 00:00:00 it must start over again to 000001/13.

Obviously it should easly acomplished using some type of algorithm, but, I’m trying to find a more efficient way to do that. Consider:

  1. It must (?) use auto-increment since the database has some concurrency (+100).

  2. Each ticket must be unique. So 000001 on 2012 is not equal to 000001 on 2013.

  3. It must be automatic. (no human interaction needed to make the reset, or whatever)

  4. It should be reasonably efficient. (a watch program should check the database daily (?) but it seems not the best solution since it will ‘fail‘ 364 times to have success only once).

The ‘best’ approach I could think of is to store the ticket number using year, such as:

12000001 – 12999999 (it never should reach the 999.999, anyway)

and then an watch program should set the auto increment field to 13000000 at 01/01/2013.

Any Suggestions?

PS: Thanks for reading… 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:44:22+00:00Added an answer on June 6, 2026 at 11:44 am

    So, for futher reference I’ve adopted the following sollution:

    I do create n tables on the database (one for each year) with only one auto-increment field wich is responsible to generate the each year unique id.

    So, new inserts are done into the corresponding table considering the event date. After that the algorithm takes the last_inseted_id() an store that value into the main table using the format 000001/12. (ticket/year)

    That because each year must have it’s own counter since an 2012 event would be inserted even when the current date is already 2013.

    That way events should be retroactive, no reset is needed and it’s simple to implement.

    Sample code for insertion:

    $eventdate="2012-11-30";
    $eventyear="2012";
    $sql = "INSERT INTO tbl$eventyear VALUES (NULL)";
    mysql_query ($sql);
    $sql = "LAST_INSERT_ID()";
    $row = mysql_fetch_assoc(mysql_query($sql));
    $eventID = $row(0)
    $sql = "INSERT INTO tblMain VALUES ('$eventID/$eventYear', ... ";
    mysql_query($sql)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have imported the data from SQl Server to HDFS. The data stored
Scenario: There is a website with 700-900 concurrent unique visitors at any given time.
Scenario The web server gets a request for http://domain.com/folder/page . The Accept-Language header tells
Scenario: I am calling a function that returns a field that the user enters
Scenario: A huge Patient class/entity with around 100 properties. But in the webpage I
Scenario: many to many relationships. table has 2 columns: UserID and UserChoiche I am
Scenario: Windows server in a AD domain hosting a Subversion repository using SVNSERVE only
Scenario : I have an ASP.NET MVC application developed in Visual Studio 2008. There
Scenario 1: Table: id column1 column2 1 bla foo 2 bla bar I want
Scenario: You have an ASP.Net webpage that should display the next image in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.