This is a discussion on @@identity when inserting multiple values within the MySQL Database forums, part of the Database Forums category; Dear group, I am writing C# Linq driver for MySql (project page at http://code2code.net/Linq_Mysql/ ) I would like ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Dear group,
I am writing C# Linq driver for MySql (project page at http://code2code.net/Linq_Mysql/ ) I would like to use multiple-value-inserts for speed, e.g.: INSERT INTO table1 (column1) VALUES (1), (2), (3); SELECT @@IDENTITY Since @@IDENTITY returns only the identity of the last row, how would you retrieve the identities of the previous rows? Can I think of multiple-value-inserts as atomic, and deduce previous IDs? Thanks, George |
|
|||
|
<snip>
> INSERT INTO table1 (column1) VALUES (1), (2), (3); SELECT @@IDENTITY > Since @@IDENTITY returns only the identity of the last row,... This is MS SQL Server code. In MySQL, the function is called LAST_INSERT_ID() and it returns the first generated ID. Look at the documentation on the MySQL site for more details. Best regards -- Willem Bogaerts Application smith Kratz B.V. http://www.kratz.nl/ |