如何获得行数导致SQL(C ANSI)中的查询? [重复]

时间:2022-06-28 09:13:51

This question already has an answer here:

这个问题在这里已有答案:

I need get the number of row result a query in SQLite in C Example:

我需要在C中的SQLite中获取行结果的查询结果示例:

SELECT name, age FROM test WHERE age > 18

How i can get the number of rows this query in SQLite C.

如何在SQLite C中获取此查询的行数

I see the command sqlite3_total_changes() to affected row (When use INSERT, UPDATE, DELETE), sqlite3_column_count() to get the number of column, but i need the number of rows, sqlite3_column_bytes().

我看到命令sqlite3_total_changes()到受影响的行(当使用INSERT,UPDATE,DELETE),sqlite3_column_count()来获取列的数量,但我需要(行,sqlite3_column_bytes数)。

I need a function equal mysql_num_rows from PHP.

我需要一个与PHP相同的函数mysql_num_rows。

case the example return 3 lines, how i can get 3 lines SQLite?

案例示例返回3行,我怎么能得到3行SQLite?

1 个解决方案

#1


0  

This is probably what you want:

这可能是你想要的:

SELECT Count(name) FROM test WHERE age > 18

This will count all rows in test where age > 18 and name is not null. If you want to count the ones with null name then use

这将计算test> age> 18且name不为null的所有行。如果要计算具有空名称的那些,请使用

SELECT Count(*) FROM test WHERE age > 18

Here is some documentation:

这是一些文档:

http://www.sqlite.org/lang_aggfunc.html

#1


0  

This is probably what you want:

这可能是你想要的:

SELECT Count(name) FROM test WHERE age > 18

This will count all rows in test where age > 18 and name is not null. If you want to count the ones with null name then use

这将计算test> age> 18且name不为null的所有行。如果要计算具有空名称的那些,请使用

SELECT Count(*) FROM test WHERE age > 18

Here is some documentation:

这是一些文档:

http://www.sqlite.org/lang_aggfunc.html