Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

@@IDENTITY equivalent

Status
Not open for further replies.

rxt

Technical User
Jan 6, 2004
2
NL
Is there a @@IDENTITY equivalent (MS SQL Server 2000) in MySQL? ::)
 
It's not exactly like @@IDENTITY, but it's darn close:

LAST_INSERT_ID([expr])
Returns the last automatically generated value that was inserted into an AUTO_INCREMENT column.
mysql> SELECT LAST_INSERT_ID();
-> 195

The last ID that was generated is maintained in the server on a per-connection basis.
 
then what does @@identity do which is not supported my mysql ?



[ponder]
----------------
ur feedback is a very welcome desire
 
If you insert many rows at the same time with an insert statement, LAST_INSERT_ID() returns the value for the first inserted row. @@IDENTITY would return the last.
 
If you have multiple inserts in one statement, last_insert_id will show you the value of the first inserted row for that session. Else it will show you the last value inserted by that session.

@@IDENTITY is a synonym for last_insert_id in version 3.23.25.
Function is for Visual Basic compatibility

"If you always do what you've always done, you will always be where you've always been."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top