简体   繁体   中英

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 joe.doe@ymail.com
2 Vivien Doe v.doe@gmail.com

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).

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM