In Mysql I am inserting a row with Insert command in a table of mysql , now I want the Id of last row Inserted , I am using
SELECT LAST_INSERT_ID() ;
But it gives me 0 as output every time .
Please help me in this.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
LAST_INSERT_ID()only returns values that have been auto-generated by the MySQL server for anAUTO_INCREMENTcolumn; when you insert a specific value, no auto-generation takes place and no value will be returned byLAST_INSERT_ID().You could assign a value to
LAST_INSERT_IDyourself:LAST_INSERT_ID(value)assignsvalueto be returned by subsequent calls toLAST_INSERT_ID(), and returns that same value. Unfortunately, this only works for integer values, and will not be useful with UUIDs.