开发者

how to call different tables in if and else part of the same database in iphone?

I have a database. It has two tables in it. I want to call one table in if condition. If if conditions fail开发者_运维知识库s 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;";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜