开发者

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

开发者 https://www.devze.com 2023-03-09 19:11 出处:网络
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.

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

精彩评论

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