How to write 'Where' clause with multiple conditions in objective C

Hello,

I am not able to figure out the exact query for ‘Where’ clause with multiple conditions.I would like to have a where clause by satisfying two conditions.I had tried few combinations, but no luck.Below is the code which i am using now,

_listQuery = [CBLQueryBuilder select:@[S_ID,S_NAME,S_OBJ,S_UniqueID] from:[CBLQueryDataSource database:_database] where:[[TYPE equalTo:[CBLQueryExpression string:_folderName]]  groupBy:group having:[TYPE equalTo:[CBLQueryExpression string:loggedInEmail]] orderBy:@[[[CBLQueryOrdering property:@"unique_id"] descending]] limit:[CBLQueryLimit limit:[CBLQueryExpression integer:30] offset:[CBLQueryExpression integer:Data_limit_str]]];

Kindly let me know, how to write where clause for multiple conditions.

My requirement

I had integrated couch db in my mail app, i will be logged in with two different accounts.If i want to retrieve the data, i will be querying it based on the folder and email id which i stored.Kindly let me know what are the things needed to be added in my query.

Don’t you just need to use an and expression? Or am I misunderstanding the question?

Even I tried to use and , but no use …Geeting an issue …can you please gimme a sample query which holds two conditions for where clause

Show what you tried, and what happened, and what was wrong with the result.

_listQuery = [CBLQueryBuilder select:@[S_ID,S_NAME,S_OBJ,S_UniqueID] from:[CBLQueryDataSource database:_database] where:([[TYPE equalTo:[CBLQueryExpression string:_folderName]] and [[EMAIL equalTo:[CBLQueryExpression string:loginEmail]]) groupBy:group having:[TYPE equalTo:[CBLQueryExpression string:loggedInEmail]] orderBy:@[[[CBLQueryOrdering property:@“unique_id”] descending]] limit:[CBLQueryLimit limit:[CBLQueryExpression integer:30] offset:[CBLQueryExpression integer:Data_limit_str]]];

Above is the expression I tried …but getting and error in the query

Well, that’s not valid Objective-C syntax; you can’t put “and” in between two method calls. You need to create an ‘and’ expression using the builder API.

_listQuery = [CBLQueryBuilder select:@[S_ID,S_NAME,S_OBJ,S_UniqueID] from:[CBLQueryDataSource database:_database] where:([[TYPE equalTo:[CBLQueryExpression string:_folderName]] andExpression:[EMAIL equalTo:[CBLQueryExpression string:loggedInEmail]]]) groupBy:group having:queryExpression orderBy:@[[[CBLQueryOrdering property:@"unique_id"] descending]] limit:[CBLQueryLimit limit:[CBLQueryExpression integer:30] offset:[CBLQueryExpression integer:Data_limit_str]]];

Tried this way also, but no luck…

@pasin, could you look at this?

@jens

I didn’t hear any update from you yet, kindly go through it…Let’s close the issue.