akosch
akosch

Reputation: 4396

How can i get the value of a pkey for a record just inserted (autoincrement)?

I'm subsequently inserting a single record in two tables. With the first insert i put the record in the main table, where the primary key value gets generated. Now i need to put some fields of this record in another table including the key value of the main table. How do i do this?

Upvotes: 4

Views: 156

Answers (1)

"SELECT LAST_INSERT_ID();" will return the last autoincrement ID generated.

Upvotes: 3

Related Questions