0

I have the address,quantity and medname fields. I need to extract the names of the stores in that address having the given medname and value should be greater than the given quantity.

image description

FirebaseRecyclerOptions<model> options =
            new FirebaseRecyclerOptions.Builder<model>()
                    .setQuery(FirebaseDatabase.getInstance().getReference(address).orderByChild(medname).equalTo(medname), model.class)
                    .build();
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    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. So you could have: `"medname_quantity": "crocin_10"` and order/filter on that. For an example of this and other approaches, see my answer here: https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen May 16 '21 at 14:57
  • @FrankvanPuffelen thats great, one more doubt, I want to check if the value is greater than the given quantity,how do I check that,say its crocin_10,quantity is 7, so how can I check if the value,that is 10, is greater than quantity, 7? – Atharva May 16 '21 at 15:16
  • You'll want to use a fixed length to store the quantities, so `crocin_010`. With that you can use `orderByChild("medname_quantity ').startAt("crocin_007")`. There's also an example of that in my linked answer. – Frank van Puffelen May 16 '21 at 15:43
  • @FrankvanPuffelen Oh thank you soo much,i was stuck at this since so long,finally got the answer,thank you soo much!! – Atharva May 16 '21 at 16:44

0 Answers0