# How to compare and get the values as per requirement from the list saved in the database

**URL:** <https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846>\
**Category:** Questions about Thunkable X\
**Tags:** firebase\
**Created:** [November 27, 2021, 7:53pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846 "2021-11-27T19:53:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![manharan.kaurms75yp](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@manharan.kaurms75yp](https://community.thunkable.com/u/manharan.kaurms75yp)\
**Post date:** [November 27, 2021, 7:53pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/1 "2021-11-27T19:53:18Z")

</div>

Hi  
I am trying to make an app where you can find a buddy to play by searching with zip code and interest. So that, children of near by area with similar interest gets displayed in the form of a list. I am unable to understand how to do it. Below mentioned is the structure of my database in which it is saved.

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/f/bfcc49693414b06c435883f84d2c0d4079f1c256.png)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 27, 2021, 10:50pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/2 "2021-11-27T22:50:59Z")

</div>

I would use Firebases firestore geoquery capabilities via the web api connector (advanced) or a service like xano

You could also look into saving locations as coordinates and using a Haversine formula to find proximal points of interest.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 28, 2021, 9:29am UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/3 "2021-11-28T09:29:19Z")

</div>

From your data structure, you are saving the children’s data under a key which is the **zip code**. if this assumption is correct then you can get the **zip code** keys as a list by using  
`get object properties` block. Once you have it as a list then use `does list .... contain ....` to shortlist only the zip code of the logged in child. From here you search the names under the selected zip code the same way you did previously.

---

<div class="post-metadata">

**Author:** ![manharan.kaurms75yp](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@manharan.kaurms75yp](https://community.thunkable.com/u/manharan.kaurms75yp)\
**Post date:** [November 28, 2021, 3:35pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/4 "2021-11-28T15:35:50Z")

</div>

I tried the same with the below mentioned block but not getting the zip code. This code gives me answer as “User, Children\_info, User, Children\_info” , User. I am unable to skip user folder and go to zipcode which is inside Children\_info.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/d/0da305f86e95b82a350b4bd4f074c039f6f02a17.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 28, 2021, 4:01pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/5 "2021-11-28T16:01:30Z")

</div>

First of all, to retrieve all data in the database use **//** not just one.

Second, if you use this then the `get object properties` will show the first available key which is in this case the user ID.

I would prefer to do it this way  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/4/249edcd6ce528eac9b46daa4143ec1e8eedee7b4.png)

For testing, I would show it in a `List Viewer` so I know it works and I can see what data is being presented.

For you, you should see a list of internet code of the user ID

Sample output  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/4/84c86e3356b3028c6c4b5b037794373b37f62218.png)

---

<div class="post-metadata">

**Author:** ![manharan.kaurms75yp](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@manharan.kaurms75yp](https://community.thunkable.com/u/manharan.kaurms75yp)\
**Post date:** [November 28, 2021, 4:56pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/6 "2021-11-28T16:56:50Z")

</div>

With your suggestion I tried this code and started getting the zip code.  
But if I ask the user to input the zipcode, I get nothing.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/0/d0ec4fbce6dffe6b9d65805177c14a8278044365.png)

This is the main input asked by the user.

 ![WhatsApp Image 2021-11-28 at 10.22.55 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/a/babc41bc8fc19cc0f749ffa305a3c7753f99f570.jpeg)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 28, 2021, 5:10pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/7 "2021-11-28T17:10:51Z")

</div>

remember this is an **EXACT** match. So if the user enters: **7760** and you are storing in the database **07760** then it fails to match.

---

<div class="post-metadata">

**Author:** ![manharan.kaurms75yp](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@manharan.kaurms75yp](https://community.thunkable.com/u/manharan.kaurms75yp)\
**Post date:** [November 28, 2021, 5:12pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/8 "2021-11-28T17:12:31Z")

</div>

I am filling 7760 only not 07760. Moreover, what code should I use two get the name of the children as per the zipcode and interest entered by the user. I am unable to get the logic for that.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 28, 2021, 5:16pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/9 "2021-11-28T17:16:00Z")

</div>

I’m not sure. I only saw part of your data. To answer, I need to see your data. Go to Firebase, open your Realtime DB and use the right side menu to export your data to a file then share it here if you think the data is not private or send it to me as a PM.

I need to see the full structure to be able to give you a meaningful answer.

---

<div class="post-metadata">

**Author:** ![manharan.kaurms75yp](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@manharan.kaurms75yp](https://community.thunkable.com/u/manharan.kaurms75yp)\
**Post date:** [November 28, 2021, 5:20pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/10 "2021-11-28T17:20:25Z")

</div>

PM sent. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 28, 2021, 9:15pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/11 "2021-11-28T21:15:43Z")

</div>

I replied to your PM. Please review and let me know.

**[By the way]**  
Putting white spaces in the end of the `key` could make it difficult even for you to figure out why it does not work.

The key **Children\_Info** has a space in the end of it. It took me a while to find it.

For others to take benefit of the coding, this is what I made in the `Screen Opens` block

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/2/f2bb123cb273f433dad7279ee96b30fa09bba19a.png)  
This extracts **two lists** from the data structure:

- Zip code list
- Interest list

See a sample output  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/2/12f77702b556c7b06659238d92ebeba37fd187df.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [February 26, 2022, 9:15pm UTC](https://community.thunkable.com/t/how-to-compare-and-get-the-values-as-per-requirement-from-the-list-saved-in-the-database/1636846/12 "2022-02-26T21:15:49Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
