Sqlite3_column_count always returns 1

sqlite3_stmt *statement; selectSql = "SELECT title FROM list"; sqlite3_prepare_v2(database, selectSql, -1, &statement, NULL); countColumn = sqlite3_column_count(statement); NSLog(@"%d",countColumn); 

why this account always returns 1
In fact, the table has 18 entries

0
objective-c sqlite3
source share
2 answers

This is because your statement only select single column ( title ). Try this and see what it returns:

 sqlite3_stmt *statement; selectSql = "SELECT * FROM list"; sqlite3_prepare_v2(database, selectSql, -1, &statement, NULL); countColumn = sqlite3_column_count(statement); NSLog(@"%d",countColumn); 
+1
source share

Do you mean a row, not a column, an account? The number of columns (in the name of your case) is really always 1.

0
source share

All Articles