How to get id of inserted row in SQL
My database table has an ID column which is an auto incremental integer. When inserting data into a table, its increment is automatic, I need to get the ID value when inserting a record.
For example: table employee = | ID | NAME | ADDRESS |
request:
insert into employee(NAME, ADDRESS) values("azzi", "test adress")
it is possible that we can modify this request to return the id shortly after the entry is made, someone can help me do that.
source to share
With the SQLite last_insert_rowid () function :
Last_insert_rowid () returns the ROWID of the last insert row from the database connection that calls the function.
source to share
SQLite
This is available using the SQLite last_insert_rowid()
function :
Last_insert_rowid () function returns the ROWID of the last insert row from the database connection that called the function. The last_insert_rowid () SQL function is a wrapper around the sqlite3_last_insert_rowid () C / C ++ interface function.
Resources: How to Get the Latest Insert ID in SQLite?
source to share