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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:39:54+00:00 2026-05-16T20:39:54+00:00

it is possible in one SQL statement to insert a record then take the

  • 0

it is possible in one SQL statement to insert a record then take the autoincrement id, and update for the same record one specific column
with this autoincrement value.

Thanks in Advance.

  • 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-16T20:39:55+00:00Added an answer on May 16, 2026 at 8:39 pm

    Strictly speaking you can not do it in a single SQL statement (as others have already pointed out).

    However, since you mention that you want to avoid making changes to legacy application let me clarify some options that might work for you.

    • If you had a trigger on the table that would update the second column, then issuing single insert will give you what you want and you might not need to change anything in the application

    • If possible, you could rename the table and in its place put a VIEW with the same name. With such simple view it might be transparent to your application (not sure if VIEW would remain updateable with your framework, but generally speaking it should)

    • Finally, with mysqli library you are free to issue multiple SQL statements, so it will be a single call to the database – which might be enough for you, depending on how exactly you define ‘single statement’

    None of the above will never be comparable to fixing the application in terms of maintainability for the guy who will inherit your code.

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

Sidebar

Related Questions

Possible Duplicate: SQL Server: Can I Comma Delimit Multiple Rows Into One Column? I
I'd like to know if it's possible to execute more than one SQL statement
I have this SQL statement below INSERT into 2011_electricity ( date, energy, daynum) VALUES
Not sure if this is possible in one Makefile alone, but I was hoping
I'm not sure if this is possible in one mysql query so I might
Is it possible to set one object's key $thumbnailContainer to the value of another
I am using the following insert statement within a tool pulling data from one
Possible Duplicates: Is there an Oracle SQL query that aggregates multiple rows into one
I am using SQL to concatenate strings together. This statement works: DECLARE @FirstNamesString nvarchar(256)
Is it possible with NHibernate and Sql Server to insert an entity and set

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.