在sqlite android中获取所选查询的最后插入列值

时间:2016-03-17 14:48:11

标签: android sqlite

我的查询给了我col_balance的总和,但我想要一个特定的(缺少的单词)最后插入的COL_BALANCE值。它必须是这样的:

select COL_BALANCE  from TABLE_NAME2  where name =(select col_bal from query where count is count -1 )

String selectQuery = " SELECT "+"sum(" + COL_BALANCE + ")"+ " FROM " + TABLE_NAME2  +  " WHERE " + COL_CUST_NAME + "= '" + name + "';";

1 个答案:

答案 0 :(得分:-1)

<强> SQLite的

可以使用SQLite last_insert_rowid()功能:

“last_insert_rowid()函数从调用该函数的数据库连接返回最后一行插入的ROWID.last_insert_rowid()SQL函数是sqlite3_last_insert_rowid()C / C ++接口函数的包装器。”