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 412397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:04:53+00:00 2026-05-12T18:04:53+00:00

Lets say you have a table with some winning numbers in it. Any of

  • 0

Lets say you have a table with some winning numbers in it. Any of these numbers is meant to be only “won” by one person.

How could I prevent 2 simultaneous web requests that submit the same numbers from both checking and seeing that the numbers is still available and then giving the prize to both of them before the number is marked as no longer being available.

The winning solution in this question feels like what I was thinking of doing, as it can also be applied in most database platforms.

Is there any other common pattern that can be applied to this?

  • 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-05-12T18:04:53+00:00Added an answer on May 12, 2026 at 6:04 pm

    These numbers are randomly generated or something?

    I would rely on the transactional semantics in the database itself: Create a table with two columns, number and claimed, and use a single update:

    UPDATE winners SET claimed=1 WHERE claimed=0 AND number=@num;
    

    Then check the number of affected rows.

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

Sidebar

Related Questions

Lets say I have one table called REVIEWS This table has Reviews that customers
Lets say I have a table with some data like the following: ID text
Lets say I have two MySQL databases with some complex table structures. Neither database
Lets say that I have a table with some key, accounts, and hits. Which
Lets say I have a list of some column values coming from a table,
So lets say I have a list with some entries(ids) of a table. I
Lets say I have a table describing cars with make, model, year and some
lets say we have a table BNK_ACCT_GRP_ST with these columns: Column Name ID Pk
Lets say I have table with following columns 1. Client - string. 2. Profit
Lets say I have table named Place with columns: placeId int not null auto_increment,

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.