Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing OR Condition using Parse Android SDK?

I am new to Parse and i am working on a Project that uses Android PARSE Sdk so i was wondering on how can i make a where query with or condition using the android sdk.

I want to make a query like this [Psuedo code]

Select * from employ where employId is ("1","2","3")

I found this on parse documentation, i don't know if it helps or not.

Edit:

This is what i found on PARSE but its not working

String[] id= {"1","2","3"};
query.whereContainedIn("employId ", Arrays.asList(id));

It returns me an empty list but if i query them one by one i get result... Can anyone tell me whats wrong ?

like image 284
Sheraz Ahmad Khilji Avatar asked May 18 '26 12:05

Sheraz Ahmad Khilji


2 Answers

You can use whereContainedIn to select specific rows. See this post you can get more ideas. https://www.parse.com/questions/different-arrays-and-wherecontainedin-for-android.

List<String> employId = new ArrayList<String>();
employId.add("1"); employId.add("2"); employId.add("2");
query.whereContainedIn("employId", employId);

If you are still not clear. check this https://www.parse.com/docs/android_guide#queries

like image 141
Ramesh_D Avatar answered May 21 '26 01:05

Ramesh_D


I have found the solution and i must say its pretty lame of PARSE to not mention this anywhere in there documentation.

The problem was that the values that i was using inwhereContainedIn method were of type String but in reality they were pointers to another table's row. I was trying to get the values using only there ids[as it is displayed on parse] but instead i had to pass the whole object in order to retrieve them. That was the reason on why it was returning empty list.

The thing is Even though it displays IDs [pointer to object in a table] we cant search using only ID's instead we have to use complete Parse objects if we want to search a table based on Specific Object.

like image 32
Sheraz Ahmad Khilji Avatar answered May 21 '26 01:05

Sheraz Ahmad Khilji