开发者

how to get rowid when insert a row to table

开发者 https://www.devze.com 2023-01-20 09:00 出处:网络
I hope to add a row to a table in a sqlite database. [NSString stringWithFormat:@\"INSERT INTO myTable (rowid,myName ) VALUES (NULL, \'%@\');\" , [aInfo myString]];

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

精彩评论

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