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?

Zainal Fahrudin
  • 536
  • 4
  • 23
Prince Kumar
  • 593
  • 2
  • 7
  • 17

1 Answers1

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:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807