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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:55:34+00:00 2026-05-29T09:55:34+00:00

After inserting new data into a table, I need to select some of the

  • 0

After inserting new data into a table, I need to select some of the new data straight after, so I can use it for inserting into another table.

The only way I can think of doing this is using the ‘datetime’ field I have in my row, but how would I retrieve the latest date/time inserted.

  1. INSERT statement with NOW() value for datetime

  2. society_select = SELECT socID, creator, datetime FROM societies.society WHERE datetime='[..datetime is the newest...]';

Hope that makes sense. Thank you

  • 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-29T09:55:35+00:00Added an answer on May 29, 2026 at 9:55 am

    There are a number of ways to do this.

    Why not make use of a trigger for this?

    When a trigger creates a record you can get the id’s of the records inserted. You can then do a select and insert new values into the relevant table.

    MYSQL has loads of resources on using triggers.

    http://dev.mysql.com/doc/refman/5.0/en/triggers.html

    Or you can get the number of rows affected then use this to get the required result set in a select statement.

    Get the last inserted ID?

    If you are inserting one row into the database at a time then you would be able to get the last inserted id from MYSQL. This will be the Primary Key value of the record you last inserted into the database.

    You would basically do something like this in mysql:

    SET @inserted_id = LAST_INSERT_ID();
    

    Or in PHP you can use the function:

    mysql_insert_id(&mysql);
    

    http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html

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

Sidebar

Related Questions

After inserting new html to DOM,I need to add some listeners to it. But
I am inserting data into two tables, however I can not figure out (after
DetailsView1.DefaultMode = DetailsViewMode.Insert; After inserting how can i Preview Data before Submitting/Inserting data in
I am inserting data into a table and sqlite3_step returns SQLITE_DONE. But sometimes there
Short version: After inserting a select element with options into the DOM with an
Keep getting this error after inserting a subdatasheet into a query and trying to
I need to bulk load a large amount of data (about 7.000.000 entries) into
When inserting a new row in a table T, I would like to check
I am a newbie to Database programming. After inserting a couple of rows into
Below is my table screenshot: Data after insertion Code in C# SqlConnection con =

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.