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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:43:03+00:00 2026-05-13T16:43:03+00:00

I have recently added an intermediary table to link two tables. Tables: Purchase: Transaction_Id

  • 0

I have recently added an intermediary table to link two tables.

Tables:

Purchase:
Transaction_Id  Purchase_Id

Schedule:
Show_Id     Price

Purchase_Schedule:
PurchaseId(fk)   Show_Id(fk)

My problem is that purhcase_id is on auto_increment. So i’m not sure where to pull that ID from.

I was going to do something like this…

INSERT INTO
    Purchase_Schedule
        (Purchase_ID, Show_ID)
    VALUES
        ((SELECT Purchase_ID FROM Purchase WHERE Transaction_ID=$transactionID),$purchaseID)";

The issue is that a Transaction_ID can have more than one purchase_ID tied to it… so this method is out.

So I believe the best way to approach this situation would be to use some sort of stored procedure to automatically update Purchase_Schedule.

Should I go with a stored procedure?
Is there a way to insert into Purchase_Schedule @ the current insert’s Purchase_ID?
or a way to return the auto_incremented Purchase_ID?

  • 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-13T16:43:03+00:00Added an answer on May 13, 2026 at 4:43 pm

    If you’re using PHP to insert the data, you can use mysql_insert_id to retrieve the value of the auto-incremented id for the last row inserted.

    You can also get it via SQL:

    SELECT LAST_INSERT_ID()
    

    See the MySQL manual for more information.

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

Sidebar

Related Questions

I have recently added a new column (age) to a database table (user). I
I have an Access table that I recently added an attachment field to. The
I am just getting started with Silverlight and have recently added a Silverlight project
I'm using an Ajax update panel and have recently added ASP.NET tracing code to
I've recently added the JQuery autocomplete plug in and have a textbox that autocompletes
I have recently updated my model, added a BooleanField to it however when I
We recently added a new TeamCity build agent. Because it doesn't have ASP.NET MVC
I have an international company that has recently been added, which is named BLA
We have just recently got our SVN server installed. My developers have added the
I recently inherited a VBA macro that needs to have validation logic 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.