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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:26:28+00:00 2026-05-25T02:26:28+00:00

Possible Duplicate: mySQL return index after insert Hy, Is there a way that after

  • 0

Possible Duplicate:
mySQL return index after insert

Hy,

Is there a way that after inserting something in mysql database (INSERT INTO table_name VALUES () ...) to retrieve ID of that insert for further manipulation ?

The old way is to make the insert and then query a SELECT on the table name . But is there any way to do this in a single query ?

Thank you very much

  • 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-25T02:26:28+00:00Added an answer on May 25, 2026 at 2:26 am

    In PHP, call mysql_insert_id(). Or directly in MySQL, call the LAST_INSERT_ID() function.

    // PHP
    echo mysql_insert_id();
    
    // PHP MySQLi
    echo $mysqli->insert_id;
    
    -- in MySQL
    SELECT LAST_INSERT_ID();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is there a way to return the id of a row that
Possible Duplicate: How to delete duplicate records in mysql database? there are duplicate rows
Is it possible to duplicate an entire MySQL database on a Linux server ?
Possible Duplicate: ClassNotFoundException com.mysql.jdbc.Driver I have included the mysql-connector-java-5.1.16-bin.jar into my Eclipse library, this
Possible Duplicate: How can I count the numbers of rows that a mysql query
Possible Duplicate: MySQL query that computes partial sums ok, the question is not clear
Possible Duplicate: MySQL - Auto Increment after delete I want to delete the last
Possible Duplicate: mySQL “Rank in Highscore”-Query I was just wondering if there is any
Possible Duplicate: Best practice: Import mySQL file in PHP; split queries How to import
Possible Duplicate: How I can create installer for website. PHP mysql I'm looking 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.