Brian Brown
Brian Brown

Reputation: 4311

How to check how many rows is in table using SOCI and C++?

Simple question. I have a table Person. I have in it two rows:

1 Joe Doe [email protected]
2 Vivien Doe [email protected]

How to write a SOCI statement, which will tell me (return) how many rows I have in my table? (Here, in my example, I have 2 rows).

Upvotes: 1

Views: 792

Answers (1)

Juraj Blaho
Juraj Blaho

Reputation: 13451

To get the number of rows in an SQL table use the count(*) function like this:

select count(*) from Person

To be more specific - to get the number into C++ variable use:

int count;
sql << "select count(*) from person", into(count);

Upvotes: 3

Related Questions