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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:32:31+00:00 2026-06-17T18:32:31+00:00

here are my tables test(tno,tname), test2(t2no,tno,…); test3(t3no,t2no,y,…); I want into insert the data into

  • 0

here are my tables

test(tno,tname),
test2(t2no,tno,...);
test3(t3no,t2no,y,...);

I want into insert the data into these three tables one by one in one transaction, so that the id generated in test1 will be referred in test2 and so on. but my problem is multiple users may access the same page at once. at that time id of one fellow is being referring in another’s record. my db has autocommit=1. For this I used, locks by locking these tables first. then I tried doing the above, so that a user will wait until its previous one’s details gets stored. though it accepts the data and keeps it in queue.

It is working, but I don’t have auto_increment enabled in any on of those tables (I can’t modify them, as I don’t have privilege to change the DB).

I tried in this way

lock table test write,test2 write,test3 write;
mysql> insert into test(tno) select max(tno) from test;
ERROR 1100 (HY000): Table 'test' was not locked with LOCK TABLES.

If I statically give the value for that id it is working fine. Everything else is working fine.

  • 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-17T18:32:32+00:00Added an answer on June 17, 2026 at 6:32 pm

    If this is the only way that rows are being inserted to the tables, you could try first select the new ID max(tno), then lock the table for READ and then insert the new row. after that unlock the READ.

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

Sidebar

Related Questions

Here is the sample data for test table I have [childId] [parentId] [present] 1
Here is a table structure (e.g. test): Field Name Data Type id BIGINT (20)
Please look at this image here is 3 tables , and out i want
Here's a procedure that I'm trying to run. It inserts into two tables -
here is my 2 tables, id for a inner join event. i want to
I have two tables, custassets and tags . To generate some test data I'd
I have a question. I have here 2 tables table 1 : products product_id
Here are the tables: CREATE TABLE [dbo].[Classes]( [ClassId] [int] NOT NULL, [ClassName] [nvarchar](50) NOT
Here are my tables in mysql: ----------------1------------------------- +---------------------------+----------+ | email | attempts | +---------------------------+----------+
I need to make a synonym search function, using MySQL. Here is the tables

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.