计数行结果集数据 [英] count rows result set data

查看:43
本文介绍了计数行结果集数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SELECT 查询,我想知道行数.

I have a SELECT query, and I would like to know the number of rows.

我试过了:

sqlite3_data_count(statement);

但它总是返回 0 作为值.

but it always returns 0 as value.

推荐答案

SQLite 即时计算结果行,因此在您实际读取所有这些行之前,您不知道行数.

SQLite computes the result rows on the fly, so you the number of rows is not known before you have actually read all those rows.

您可以执行单独的查询 SELECT COUNT(*) FROM (original query),但这意味着该查询会执行两次.

You could execute a separate query SELECT COUNT(*) FROM (original query), but this would mean that the query is executed twice.

相反,您应该使用动态增长的数据结构.

Instead, you should use a data structure that grows dynamically.

这篇关于计数行结果集数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆