I have written this code :-
[database open];
NSString *stringQuery = [NSString stringWithFormat:@"SELECT email, firstName, id, lastName, phone FROM contacts WHERE id = '%@'", _stringID];
NSString *stringQuery2 = [NSString stringWithFormat:@"SELECT id, status FROM members WHERE id = '%@'", _stringID];
FMResultSet *result = [AppDel.database executeQueryWithFormat:stringQuery, stringQuery2];
if ([result next])
{
labelEmail.text = [result stringForColumn:@"email"];
labelFirstName.text = [result stringForColumn:@"firstName"];
labelLastName.text = [result stringForColumn:@"lastName"];
labelCellPhone.text = [result stringForColumn:@"phone"];
labelSignInStatus.text = [result stringForColumn:@"status"];
}
[result close];
[database close];
Its gives me the value at labelCellPhone.text when i pass it through labelSignInStatus.text they showing "Warning: I could not find the column named 'status'" & when i pass the query in Sqlite browser they give me correct result.I have also create FMResultSet object again named FMResultSet *result1 & pass query its showing me the same error. Can anybody help me that how can i pass two queries in FMResultSet. Thanks
You can't pass 2 queries to executeQueryWithFormat. That is not what it was meant for. You can pass one query and then some parameters. If you are going to format the sql yourself, then just use executeQuery:(NSString *) sql
It's not totally clear what you are trying to do here, but you probably need to do a SQL join. So your problem is a SQL question, not a FMResult set question I think.
Maybe you need something like this:
NSString *stringQuery = [NSString stringWithFormat:@"SELECT c.email, c.firstName, c.id, m.status c.lastName, c.phone FROM contacts c, members m where c.id=m.id and c.id='%@'", _stringID];
FMResultSet *result = [AppDel.database executeQuery:stringQuery];
So that would return you a row where the contact has the same id as the member. Then the rest of your code should work.