如何在 SQLite 中获取最后一个插入 ID? [英] How to get last insert Id in SQLite?
问题描述
SQLite 中是否有任何内置函数可以获取最后插入的行 ID.例如:- 在 mysql 中,我们有 LAST_INSERT_ID()
这种函数.对于 sqllite,任何可用于执行相同过程的函数.
Is there any built in function available in SQLite to fetch last inserted row id.
For eg :- In mysql we have LAST_INSERT_ID()
this kind of a function. For sqllite any function available for doing the same process.
请帮帮我.
谢谢
推荐答案
SQLite
可以使用 SQLite last_insert_rowid()
函数:
last_insert_rowid()函数返回最后一行的ROWID从调用该函数的数据库连接插入.这last_insert_rowid() SQL 函数是围绕sqlite3_last_insert_rowid() C/C++接口函数.
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.
PHP
这个函数的PHP版本/绑定是sqlite_last_insert_rowid()
:
返回最近插入的行的rowid数据库 dbhandle,如果它是作为自动增量字段创建的.
Returns the rowid of the row that was most recently inserted into the database dbhandle, if it was created as an auto-increment field.
这篇关于如何在 SQLite 中获取最后一个插入 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!