开发者

how to get rowid when insert a row to table

I hope to add a row to a table in a sqlite database.

[NSString stringWithFormat:@"INSERT INTO myTable (rowid,myName ) VALUES (NULL, '%@');" , [aInfo myString]];

rowid is auto increment.

After insert the row, I hope to get the rowid that generate by sqlite autom开发者_如何学JAVAatically.

Is it possible?

welcome any comment

Thanks


You can get the new generated id with the last_insert_rowid() function. See http://www.sqlite.org/c3ref/last_insert_rowid.html

You do not say what language are you using, but search in your SQLite library implementation for last_insert_rowid function...


you can use select max(rowid) from myTable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜