Can I use SELECT COUNT(*) from tableName in a C program?
If so, how do I fetch the results? I don’t want to use a loop because I only want the number of rows, not the data.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you execute the query
SELECT COUNT(*) from tableName, the result is a table like with other queries, but that result table has only one column and only one row, which contains the count value.Call
sqlite3_prepare_v2normally, thensqlite3_step, which steps to the first (and only) row.Call
sqlite3_column_intto get the value.The next call to
sqlite3_stepwill then returnSQLITE_DONE.