Is there any easy way to get the number of rows returned by a sqlite statement? I don't want to have t开发者_如何学Co go through the process of doing a COUNT() first. Thanks.
On each call to sqlite_step
, increment a variable by 1.
If you want the row count in advance, then there's no easy way.
To count all entries in a table, you can use the following SQL statement:
SELECT COUNT(*) FROM "mytable" where something=42;
Or just the following to get all entries:
SELECT COUNT(*) FROM "mytable";
In case you have already done the query, and just want the number of entries returned you can use sqlite3_data_count()
and sqlite3_column_count()
depending on what you want to count.
精彩评论