# Querying Local DB to Return List of Items that Have a Match to a Query in their Row

**URL:** https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565
**Category:** Questions about Thunkable X
**Created:** [August 9, 2019, 3:23pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565 "2019-08-09T15:23:23Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![martymcsupafly](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/martymcsupafly/32/40331_2.png) [@martymcsupafly](https://community.thunkable.com/u/martymcsupafly)
#### Post date: [August 9, 2019, 3:23pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/1 "2019-08-09T15:23:23Z")

</div>

Sorry if the topic doesn’t make sense, I wasn’t sure the best way to describe it. I’ve tried searching the community, but this same trouble describing what I am hoping to do has led to a yield of no results.

I am sure this is pretty basic, but I’m just getting started with Thunkable X and having a hard time building this out.

I am using a Local DB with several columns. I have a populated list of all 50 states. When one of the states is clicked, I need to query the States column of the Local DB and return the item from the Name column to populate the list.

I would be extremely appreciative if someone could show me how to build this out in Thunkable X. Once I have that working, that same block will allow me to do a lot of the other things I am hoping to do!

Thank you!

---

<div class="post-metadata">

### Author: ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)
#### Post date: [August 9, 2019, 3:54pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/2 "2019-08-09T15:54:35Z")

</div>

Hello there,  
Welcome to our Community 😄 🎉 🎉

> [@martymcsupafly](#):
>
> When one of the states is clicked,

So, I assume that u are using a listviewer to select States.

I think, this can help u -

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/c/ecc53bf852ae040e884d0cd7748f0a7611e3b046.png)

* * *

Hope it helps 😄  
Thanks! 🎉

---

<div class="post-metadata">

### Author: ![martymcsupafly](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/martymcsupafly/32/40331_2.png) [@martymcsupafly](https://community.thunkable.com/u/martymcsupafly)
#### Post date: [August 9, 2019, 4:02pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/3 "2019-08-09T16:02:04Z")

</div>

Thank you for the quick reply!

What I’m hoping to accomplish is a little more complicated than that unfortunately.

You’re correct about the list viewer with the 50 items (50 states).

The local DB is filled with many locations. Each row has a column for the location name, a column for the address, a column for the state, etc.

What I am hoping to do is when they click on, let’s say Florida, it will query the Local DB for all of the rows where the column States equals Florida and return the result for the column Name in that row to the List Viewer.

---

<div class="post-metadata">

### Author: ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)
#### Post date: [August 10, 2019, 2:50am UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/4 "2019-08-10T02:50:28Z")

</div>

Hello there, 👋

## Okay. So here’s what u should do :

* * *

# Solution #1

If yr **listview items** & **local db States’ column items** are ditto (the same names & letterCASE), and **arranged the same** , like -  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/7/d784349d934f66c06f2c7514eb676671cf13c1e9.png)  
(Both have same names at same indexes)

## Then, this should work for u -

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

## Else, (Both do not have same names at same indexes)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/6/96ba05d821faa15e8d71a214edf747863a5db548.png)

## Hope it helps! 😄

# Thanks a lot! 😉

---

<div class="post-metadata">

### Author: ![martymcsupafly](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/martymcsupafly/32/40331_2.png) [@martymcsupafly](https://community.thunkable.com/u/martymcsupafly)
#### Post date: [August 10, 2019, 2:24pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/5 "2019-08-10T14:24:03Z")

</div>

This looks like it’s getting very close to what I am hoping to do!

The table will look more like this:

![25%20AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/9/398221c9d31a5305b9031eea7c54f316379ddda2.png)

When the list item Alabama is clicked, it would return Location 1, Location 6, and any others where State matches the clicked list item. There will be dozens of results for each of the 50 states.

Thank you very much for your assistance so far!

---

<div class="post-metadata">

### Author: ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)
#### Post date: [August 10, 2019, 3:10pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/6 "2019-08-10T15:10:17Z")

</div>

#### Hi, @martymcsupafly! 👋

* * *

\*\*Try this : \*\*

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/5/e590d93b9003ca37cc5466bf97118aac7a2b1869.png)

* * *

## Hope it helps! 😉

---

<div class="post-metadata">

### Author: ![martymcsupafly](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/martymcsupafly/32/40331_2.png) [@martymcsupafly](https://community.thunkable.com/u/martymcsupafly)
#### Post date: [August 10, 2019, 4:10pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/7 "2019-08-10T16:10:10Z")

</div>

This is starting to make a lot more sense! What I’m hoping to do with this list now is to take that list that will return all Locations and fill the List Viewer with all of the results.

 ![01%20PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/a/7aa3f741f8c1db1d20325a82bc44c8349c2ae9ae.png)

Here’s what I’ve got based on what you suggested, but I’m not entirely sure how to add those results to the List Viewer, whether it be adding one at a time in the loop or having the loop create another list and then setting the List Viewer text items to that list?

---

<div class="post-metadata">

### Author: ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)
#### Post date: [August 11, 2019, 3:11am UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/8 "2019-08-11T03:11:41Z")

</div>

# Here’s the solution for the listviewer : 😊

* * *

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

* * *

## Hope it helps! 😉

---

<div class="post-metadata">

### Author: ![jane](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jane/32/27575_2.png) [@jane](https://community.thunkable.com/u/jane)
#### Post date: [August 11, 2019, 7:24pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/9 "2019-08-11T19:24:22Z")

</div>

Hi there,

You can see a tutorial on searching and filtering a LocalDB here:  
[http://community.thunkable.com/t/search-filter-localdb/68902?u=jane](http://community.thunkable.com/t/search-filter-localdb/68902)

Thanks,  
Jane

---

<div class="post-metadata">

### Author: ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)
#### Post date: [August 12, 2019, 2:07am UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/10 "2019-08-12T02:07:54Z")

</div>

This is also very helpful 😄

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 12:11pm UTC](https://community.thunkable.com/t/querying-local-db-to-return-list-of-items-that-have-a-match-to-a-query-in-their-row/175565/11 "2024-11-08T12:11:56Z")

</div>


