当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - 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 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;";
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: