8

My database table has ID column which is an auto incremental integer. While inserting data to the table its increment automatically I need to get the value of ID when a record is inserted.

Eg: table employee = |ID| NAME | ADDRESS|

the query is :

insert into employee(NAME, ADDRESS) values("azzi", "test adress")

there is a possible that we can change this query to return the ID soon after record inserted, some one help me to do that.

Azad
  • 4,593
  • 3
  • 25
  • 52
  • Your question may already asked http://stackoverflow.com/questions/8892973/how-to-get-last-insert-id-in-sqlite .. Please check the link.^_^ – do_Ob Jul 27 '15 at 07:19

2 Answers2

4

With the SQLite last_insert_rowid() function:

The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function.

namezero
  • 1,951
  • 3
  • 19
  • 35
1

SQLite

This is available using the SQLite last_insert_rowid() function:

The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked 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 last insert Id in SQLite?

Community
  • 1
  • 1
do_Ob
  • 689
  • 1
  • 5
  • 22