# Comparing a variable to a field in database

**URL:** https://community.thunkable.com/t/comparing-a-variable-to-a-field-in-database/2742507
**Category:** Questions about Thunkable X
**Tags:** help
**Created:** [December 7, 2023, 5:56pm UTC](https://community.thunkable.com/t/comparing-a-variable-to-a-field-in-database/2742507 "2023-12-07T17:56:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jc953j](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jc953j](https://community.thunkable.com/u/jc953j)
#### Post date: [December 7, 2023, 5:56pm UTC](https://community.thunkable.com/t/comparing-a-variable-to-a-field-in-database/2742507/1 "2023-12-07T17:56:52Z")

</div>

Hi,

Im creating a project which revolves around making a hotel reservation app. However I’m currently trying to filter out results in regards to the input of the user. In my database there is a field called country which I would like to compare with the destination the user inputs. If both of these variables are the same then it should show in the list, if not then it shouldn’t.

Any help would be appreciated, thanks.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [December 7, 2023, 6:09pm UTC](https://community.thunkable.com/t/comparing-a-variable-to-a-field-in-database/2742507/2 "2023-12-07T18:09:10Z")

</div>

![Welcome Thunkable Beaver 30%](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/1/21bca149f78e77f9020aa2832040e922ea615770.png)

It’s really important to provide enough details for us to be able to help you. This includes screenshots or a link to your project so we can see what you’ve tried and determine why something might not be working.

See this: [How to ask Great Questions v2.0](https://community.thunkable.com/t/how-to-ask-great-questions-v2-0/2689983)

---

<div class="post-metadata">

### Author: ![jc953j](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jc953j](https://community.thunkable.com/u/jc953j)
#### Post date: [December 7, 2023, 6:16pm UTC](https://community.thunkable.com/t/comparing-a-variable-to-a-field-in-database/2742507/3 "2023-12-07T18:16:06Z")

</div>

Hi,

sorry about that. Here is a screenshot of the database  
 ![Screenshot 2023-12-07 181033](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/c/7caee375e988d1ecade14bf76a2feebd5ccfde24.png)  
I’m trying to compare the destination input by the user to the country field, if they are the same then the visibility should be true, otherwise false. here is a link to my project too:  
[https://x.thunkable.com/copy/22efe5937f57cdf29229f7f2aa6fa12a](https://x.thunkable.com/copy/22efe5937f57cdf29229f7f2aa6fa12a)

thanks

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [December 7, 2023, 6:47pm UTC](https://community.thunkable.com/t/comparing-a-variable-to-a-field-in-database/2742507/4 "2023-12-07T18:47:20Z")

</div>

If you have a set number of destinations, it might be better to have the user choose one from a simple list or data viewer instead of typing it in. Because if they type “singopore” or “netherlinds” your app isn’t going to recognize that as a valid destination. Using a component designed for listing information allows you to use the green value blocks associated with that component to easily search for the user’s input.

The way you’re looping through data source values is a common way people try to look up values but it’s not the most efficient:

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

Instead, use a method I describe here: [Thunkable and returns a corresponding value from my sheet - #2 by tatiang](https://community.thunkable.com/t/thunkable-and-returns-a-corresponding-value-from-my-sheet/2446081/2)

You should also be aware that stored variables will slow down Thunkable. It’s better to use app variables inside of loops (or generally any time that you aren’t actually setting the value of a stored variable). So you can assign a stored variable to an app variable and then use the app variable throughout your code.

---

<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: [March 6, 2024, 6:48pm UTC](https://community.thunkable.com/t/comparing-a-variable-to-a-field-in-database/2742507/5 "2024-03-06T18:48:11Z")

</div>

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