0

I need equivalent query of

SELECT PlayerName FROM GameScores WHERE Department = 'HR' OR Department = 'IT' OR Department = 'Marketing'

In Firebase for android , I don't want multiple call, just one request and get all data that match with where clause key. How I can do it?

2
  • stackoverflow.com/questions/26700924/… Commented Nov 22, 2017 at 14:04
  • @Martin: the question you link is about filtering on multiple properties, while this one wants to filter on multiple values of a single property. Commented Nov 22, 2017 at 14:37

1 Answer 1

3

The only way to filter a property on multiple values in Firebase is if those values are in a range. For example, you could get all items matching your values with:

ref.child("GameScores")
   .orderByChild("Department")
   .startAt("HR")
   .endAt("Marketing")

The problem with this is that it also matches scores from other departments whose name is between HR and Marketing, such as

There is no way in either the Firebase Realtime Database or Cloud Firestore to pass multiple separate values into a query. You will have to execute a separate query for each value and merge them client-side.

Also see:

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Frank I tried your solution and i have restructure my db

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.