0

I need to query the data

enter image description here

Can Firebase query the data like SQLserver have filter data ?

For example , SQLserver use "where" "and" to find data more specifically.

I have try to getkey and get value ... but it can't find the node "emj394m6603d".

How to query the data which cofffeeNo is "美式咖啡" and store is "南店" and style is "中冰" , and delete all data under the node "emj394m6603d" ? (Only need to delete a piece of data )

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
徐瑞鴻
  • 33
  • 5
  • If you want to use SQL databases, why aren't you using one? If you want to use Firebase, maybe you should restructure your data so that you can query it easier. Delete: https://firebase.google.com/docs/database/android/read-and-write#delete_data – OneCricketeer Jul 17 '17 at 13:18

1 Answers1

1

No, you cannot query data in Firebase as you do in SQLserver. Firebase is a NoSQL database, so WHERE clauses does not exist. Unfortunately Firebase does not provide also a query that uses more than one condition.

So in order to solve your problem, you need to restructure your database a little bit. So you need to add antoher field named: cofffeeNo_store_style that has the value of: "美式咖啡_南店_中冰". So having this, you can query your database only once, by this new field.

To delele a value or an entire node from your Firebase database, you only need to use removeValue() method directly on the reference like this:

yourRef.removeValue();

Hope it helps.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193