我需要读取以下查询的列值
SELECT strtime('%Y-%m', created_at) as field FROM table GROUP BY field
列字段的类型是 3(我假设它是博客),但我需要字符串
我该怎么办?
更新
const char* sql = "SELECT CAST(strftime('%Y', created_at) as INTEGER) as year FROM table GROUP BY year
if (SQLITE_OK == sqlite3_prepare_v2([AppDelegate db], sql, -1, &queryhandle, NULL)){ while(SQLITE_ROW == sqlite3_step(queryhandle)){
NSSTring* year = [NSString stringWithFormat:@"%d",sqlite3_column_int(queryhandle, 0)];
这段代码给了我 3460 作为年份
(已检查强制转换为整数,并强制转换为 varchar 和 sqlite3_column_text 函数)