I got three SELECT
statements connected with UNION ALL
. I set up the compound statement such that sqlite3_prepare_v2()
would prepare the resulting rows for me. If I were to make use of the resulting data, could I use a for()
loop?
int i;
for(i = 0; sqlite3_step(res) == SQLITE_ROW; i++) {
if (i == 0) data1 = sqlite3_column_int(res,0);
else if (i == 1) data2 = sqlite3_column_int(res,0);
else data3 = sqlite3_column_int(res,0);
}
Is this supposed to work? I've tried it but it gives me garbage data. Is there an alternative way to implement this?