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;";
}
精彩评论