0

I'm studying Firebase Realtime Database and I'd like to do a query like this.

Select * from product where value >= 10 and quantity > 20 

This is the database.

product

  • name: Barbie
  • value: 15
  • quantity: 25

I'm using this code. It's working, but I'd like to have the result for these 2 conditions (value >= 10 and quantity > 20) not only for one condition.

mDatabase = FirebaseDatabase.getInstance().getReference();

query = mDatabase.child("product").orderByChild("value").startAt(10);

FirebaseRecyclerOptions<Product> options = new FirebaseRecyclerOptions.Builder<Product>()
      .setQuery(query, Product.class)
      .build();
Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
  • Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property, but that won't be possible here since you want two range filteers. For an example of what is possible and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Apr 07 '22 at 00:23

0 Answers0