On 2018/01/19 2:16 PM, Simon Slavin wrote:

On 19 Jan 2018, at 12:06pm, x <tam118...@hotmail.com> wrote:

Int Count=0;

while (sqlite3_step(...)) Count++;
That’s a slow way to count rows.  Do it in SQL:

        SELECT COUNT(*) FROM MyTable WHERE b > 11;

You get just one row back which makes everything far faster.

I think the OP is not interested in the actual row count for that specific query, rather he is interested in a mechanism by which he can receive both the rows and their count (and possibly numeric index) in the space of a single query, hence the counter while looping the cursor - which is in fact the very best way to do it.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to