MySQL Forums
Forum List  »  Newbie

Re: LAST INSERT ID
Posted by: Ike Walker
Date: September 26, 2007 01:37PM

LAST_INSERT_ID() returns the auto_increment value from the last insert you executed in your session. It is not meaningful outside the scope of a session.

If you want the maximum auto_increment value from the table, select it like this:

SELECT MAX(cd_Code) FROM tb_Client

If you want to see the entire row, do this:

SELECT * FROM tb_Client order by cd_Code desc limit 1

If you insert a row into that table and want to know its auto_increment value, you can use LAST_INSERT_ID(), but only while the session is still active:

SELECT LAST_INSERT_ID()

Options: ReplyQuote


Subject
Written By
Posted
September 26, 2007 08:31AM
Re: LAST INSERT ID
September 26, 2007 01:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.