Sqlite3 C Api Number Of Rows
Can I use SELECT COUNT(*) from tableName in a C program? If so, how do I fetch the results? I don't want to use a loop because I only want the number of rows, not the data.
Solution 1:
When you execute the query SELECT COUNT(*) from tableName
, the result is a table like with other queries, but that result table has only one column and only one row, which contains the count value.
Call sqlite3_prepare_v2
normally, then sqlite3_step
, which steps to the first (and only) row.
Call sqlite3_column_int
to get the value.
The next call to sqlite3_step
will then return SQLITE_DONE
.
Post a Comment for "Sqlite3 C Api Number Of Rows"