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
  • 268,359
  • 30
  • 341
  • 380
DanielM96
  • 103
  • 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
  • 73,993
  • 25
  • 133
  • 124
  • 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