开发者

Number of rows returned in a sqlite statement

开发者 https://www.devze.com 2022-12-30 06:28 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消