MENU

Find the Last inserted Auto increment ID in MYSQL with ASP

blank

Find the Last inserted Auto increment ID in MYSQL with ASP

It’s taken me ages to find out how to do this (what turns out to be a) relatively simple operation.

Here’s the problem. Table 1 has a user_id which is auto incremented by MYSQL. Table 2 has an auto incremented login_id but also requires the user_id. Here’s how we get one ID from one table to the other:

objRS.source = “Select LAST_INSERT_ID() from Table1”
objRS.open
LastID = objRS(“LAST_INSERT_ID()”)
objRS.Close

Simple! We can then refer to the LastID in Table 2

Filed Under:

blank
About The Author
Katy is always trying to be more productive one day at a time! Whether it's analogue, digital, motivational or psychological who'll try any system that will help her get things done and get organised. As well as running FlippingHeck.com, she also loves making music and reviewing things.
  • Follow Katy Whitton on:
  • blank
  • blank
  • blank
  • blank
  • blank
  • blank
  • blank
Please Note: This post has been included on FlippingHeck.com as we believe it contains information useful to our readers. We are in no way affiliated with any product or service that the author may link to in their personal bio

Subscribe to our mailing list

Join Hundreds of readers who have access to exclusive downloads and content

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.