FMDB SQLite question: row count of a query?

前端 未结 8 2031
别那么骄傲
别那么骄傲 2021-02-01 17:41

does anyone know how to return the count of a query when using FMDB? If I executeQuery @\"select count(*) from sometable were...\" I get an empty FMResultSet back. How can I get

8条回答
  •  无人及你
    2021-02-01 18:36

    try this. It works for me. Iterating all the records is not recommended.

    FMResultSet *rs = [db executeQuery:@"select count(FIELD) as cnt from TABLENAME"];
    while ([rs next]) {
        NSLog(@"Total Records :%d", [rs intForColumn:@"cnt"]);
    }
    

    May be you should check your Where clause.

提交回复
热议问题