问题描述:

I have a database. It has two tables in it. I want to call one table in if condition. If if conditions fails i wanted to call the second table in the else part.

Can any one help by providing the sample code.

Thanks in advance

网友答案:

This is super-simple:

char *tableName = (somecondition) ? "someTable" : "someOtherTable";
网友答案:

What kind of database is it? If sqlite, simply modify sql command with the condition.

NSString* sql;
if (cond) {
    sql = @"SELECT id from foo;";
} else {
    sql = @"SELECT * from bar;";
}
相关阅读:
Top