# Select Table From Dropdown List

**URL:** <https://forum.inductiveautomation.com/t/select-table-from-dropdown-list/19445>\
**Category:** Ignition\
**Created:** [August 29, 2018, 2:43pm UTC](https://forum.inductiveautomation.com/t/select-table-from-dropdown-list/19445 "2018-08-29T14:43:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![terance.whitmire](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@terance.whitmire](https://forum.inductiveautomation.com/u/terance.whitmire)\
**Post date:** [August 29, 2018, 2:43pm UTC](https://forum.inductiveautomation.com/t/select-table-from-dropdown-list/19445/1 "2018-08-29T14:43:19Z")

</div>

Hello all,

Quick question. I have a database with multiple tables. In Ignition, I have a dropdown that list each table and I would like to be able to display each database table’s dataset dynamically in an iginition table located underneath the dropdown.

What I would like to do is to bind, say the Dropdown.selectedLabel “Table 1” to the data of my database Table1 and display it below. I would need to repeat this 10 times, to have 10 different dropdown labels that are bound to display 10 different datasets. Is this possible?

I’m using Ignition 7.9 and SQL Server. I have already connected my database to ignition and am pulling data easily. I’m just stumped on the above situation. Any help would be great.

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [August 29, 2018, 4:17pm UTC](https://forum.inductiveautomation.com/t/select-table-from-dropdown-list/19445/2 "2018-08-29T16:17:29Z")

</div>

The specifics here would depend on the kind of database you’re using, etc… but the first method for accomplishing this that comes to my mind is:

Set up your dropdown list so that it has two columns in its Data property, “Value” and “Label”, both strings. Populate “Value” with the actual names for your database tables, and “Label” with the names you want to display on your dropdown. Then put a property change script on the dropdown… something like this:

```auto
if event.propertyName == "selectedStringValue":
	dbQuery = "SELECT * FROM " + event.source.selectedStringValue
	dbData = system.db.runQuery(dbQuery)
	event.source.parent.getComponent('Table').data = system.dataset.toDataSet(dbData)
```

You should take a look at the documentation for [system.db.runQuery](https://docs.inductiveautomation.com/display/DOC79/system.db.runQuery), to make sure that you are using it right. For example, if the db you’re accessing isn’t the default db for this project, then you’ll wnat to enter it in the second parameter.

Also, some SQL servers have different syntaxes from others. Generally, SELECT statements are the same, but you never know, so basically you should tweak the above code to make it work for your specific application.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 29, 2018, 4:21pm UTC](https://forum.inductiveautomation.com/t/select-table-from-dropdown-list/19445/3 "2018-08-29T16:21:33Z")

</div>

> [@zacslade](#):
>
> Then put a property change script on the dropdown.. something like this:

Or just reference the table name in a SQL binding, like so:

```auto
SELECT *
FROM {Root Container.Drop Down.selectedStringValue}

```

---

<div class="post-metadata">

**Author:** ![terance.whitmire](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@terance.whitmire](https://forum.inductiveautomation.com/u/terance.whitmire)\
**Post date:** [August 29, 2018, 5:48pm UTC](https://forum.inductiveautomation.com/t/select-table-from-dropdown-list/19445/4 "2018-08-29T17:48:11Z")

</div>

It was a combination of your advice and @zacslade’s advice that solved my problem. Thank you both very much! I did take a look at the [system.db.runQuery](https://docs.inductiveautomation.com/display/DOC79/system.db.runQuery) and it helped me understand the logic behind the statements you all provided.
