小编nox*_*nox的帖子

SQLite count(*)如何获得结果?

我已经完成了这个代码来计算db中的行数

    int rows = 0;
if (sqlite3_open([[SqliteManager getDBPath] UTF8String], &database) == SQLITE_OK) {
    const char *sql = "select count(*) from artheca";
    sqlite3_stmt *countstmt;

    if(sqlite3_prepare_v2(database, sql, -1, &countstmt, NULL) == SQLITE_OK) {              
        NSLog(@"inside");
        rows = sqlite3_column_int(countstmt, 0);
    }
}
else
    sqlite3_close(database);
return rows;
Run Code Online (Sandbox Code Playgroud)

但结果总是0.

所以,我不确定是否rows = sqlite3_column_int(countstmt, 0);是获得行数的正确陈述......是否正确?

sqlite iphone count

4
推荐指数
1
解决办法
8491
查看次数

标签 统计

count ×1

iphone ×1

sqlite ×1