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

  • Home
  • SEARCH
  • 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 9006719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:29:16+00:00 2026-06-16T01:29:16+00:00

I need to set an unique number with rang from 1-99 for each transaction,

  • 0

I need to set an unique number with rang from 1-99 for each transaction, says,

  • Transaction 1: seq_num = 1;
  • Transaction 2: seq_num = 2;
  • …
  • Transaction 99: seq_num = 99;
  • Transaction 100: seq_num = 1; (rollover)

I am thinking to create a MySQL table named SEQ_NUM, with only field named ‘id’, so every time, I can run the following sql,

Update SEQ_NUM set id = id + 1;

to get an seq_num, if seq_num = 100, then I will set seq_num =1 and run another sql to reset id as,

Update SEQ_NUM set id = 1;

But I am not sure it is guarantee working, because there could be more than one transaction running at the same time, and before I run

Update SEQ_NUM set id = 1;

There could be another transaction asking for a sequence number, and the 101 will be returned.

Any idea?

Thanks!

  • 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-16T01:29:17+00:00Added an answer on June 16, 2026 at 1:29 am

    I think the modulus operator is of use here. Perhaps the basic idea you have will work, but allow that SEQ_NUM to grow unbounded, and when you select it for your sequence number, wrap it in MOD().

    But in reality, I would wonder if you already had a unique & auto-incrementing ID column which could be used this way (i.e. SELECT MOD(id, 99) as trans_seq)…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to set up a MySQL environment that will support adding many unique
I have a number of tables I need to convert from mySQL to SQL
I need to assign a list of employees a unique number from 1 to
I'm trying to SELECT, and get a unique result set, from a MySQL database,
I need a data structure that holds unique values (like a set), but also
i need to set an integer to start from 001 instead of only 1
In a Django application I need to create an order number which looks like:
I need some advice regarding updating a large number of records in a MySql
the id filed is a Integer(from 1 to Integer.MAX_VALUE,unique), I don't need range searches
I want to set a unique ID for each item that is added to

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.