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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:11:31+00:00 2026-05-28T05:11:31+00:00

In the users table I am adding new rows, these rows need to each

  • 0

In the users table I am adding new rows, these rows need to each contain a reference the id of a unique row in another “access keys” table.

Some of these users rows may be added simultaneously from many threads. I know these will be database blocking with the writes so not truly simultaneously. So maybe this is not a concern?

So I have a php script that creates the new user row, and I have the access keys table populated with many rows. How do I generate the reference to the id of a unique row in the “access keys” table and how do I know it is unique?

  • 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-28T05:11:31+00:00Added an answer on May 28, 2026 at 5:11 am

    You do it sequentially from whatever thread(s) are doing the insertion:

    1) add row to the users table
    2) retrieve ID of this new row
    3) insert into access keys table using the ID retrieved in #2
    4) go to 1) until completed

    MySQL can securely return the last ID it created as part of an insert query for each connection – an insert done by some OTHER thread will not overwrite another thread’s “last insert id” – the last insert id kept on a per-connection basis.

    With this structure, you can have as many threads as you want doing inserts, and none of them will step on each other’s toes, as they’re all getting their own distinct “last id”.

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

Sidebar

Related Questions

I have a table called newDataTable where I am adding new rows dynamically with
I have a items table with 1 million rows and a users table with
I'm adding a row to a UITableView section when the user switches the table
My problem is that I am adding a row to a HTML table dynamically
users table +-----+-----------+ | id | username | +-----+-----------+ | 1 | tom |
I have users table. There are three other tables: developers, managers, testers. All of
i have users table and i have posts table i want select from users
I'm trying to create a Users table that only has OpenId registrations, exactly like
I have a table called UserPermissions with a FK to the users table by
I want to add 100 entry to users table numbers field, random characters length

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.