0

I have an android app using google firebase. In this i have the query working with one input using .equalsTo as shown below:

Query firebaseSearchQuery = mCarDatabase.orderByChild("make").equalTo(make);

As show it orders by car make and takes in a string with the make. I have am not sure how to approach adding another string input to the query for example i wanted to search the query by model too and what i tried was adding another .equalTo(model) but that breaks the application. Any assistance here would be a great help thank you.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
DanielM96
  • 103
  • 1
  • 3
  • 12

1 Answers1

1

You can only use one orderByChild() or one orderByKey() but there are different queries that you can use like:

limitToFirst()
limitToLast()
startAt()
endAt()
equalTo()

more info here:

https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query.html

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
  • is there any way to perform a query with multiple strings ? – DanielM96 Mar 11 '18 at 18:10
  • 1
    @DanielM96 what you are thinking about does not work as said in the first answer here and in my answer here: https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase (but there are some workarounds there) – Peter Haddad Mar 11 '18 at 18:12