# Indirect Query Selection For Tables In Ignition Perspective

**URL:** <https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 13, 2024, 5:50pm UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191 "2024-07-13T17:50:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AydHA](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@AydHA](https://forum.inductiveautomation.com/u/AydHA)\
**Post date:** [July 13, 2024, 5:50pm UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191/1 "2024-07-13T17:50:06Z")

</div>

I have a many different queries that follow the same file structure and name, just a different ending number. I was wondering if I could set a parameter value as the path to change the value of a table to parse switch the query that is displayed in the table.

I was hoping to do this through a dropdown to select and change a parameter ideally.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/454956dc78c1e903aa571a14372c4a028f96cc18.png)

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [July 13, 2024, 5:52pm UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191/2 "2024-07-13T17:52:18Z")

</div>

Do you want to dynamically pick the table? Or just a different parameter in the query?

Can you show your query?

---

<div class="post-metadata">

**Author:** ![AydHA](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@AydHA](https://forum.inductiveautomation.com/u/AydHA)\
**Post date:** [July 13, 2024, 5:57pm UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191/3 "2024-07-13T17:57:03Z")

</div>

I would like to dynamically pick the table by changing the query. This is the format for each of the queries, where the '%1016%' just has a number"

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/4/8413e9846eea7d2597f06f36c15467251f1376b0.png)

Changing the query dynamically was my first idea, I'm open to other ways of doing this, was just what seemed most viable to me at first glance.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [July 13, 2024, 6:40pm UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191/4 "2024-07-13T18:40:02Z")

</div>

So you want the like statement to be a parameter?

Or the table in the from statement? What you want and what you said are two different things.

---

<div class="post-metadata">

**Author:** ![AydHA](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@AydHA](https://forum.inductiveautomation.com/u/AydHA)\
**Post date:** [July 13, 2024, 6:41pm UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191/5 "2024-07-13T18:41:07Z")

</div>

Table From The Statement

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [July 13, 2024, 6:54pm UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191/6 "2024-07-13T18:54:17Z")

</div>

You have to use a query string in your named query.

They are not sanitized, so risk of SQL injection is high.

---

<div class="post-metadata">

**Author:** ![Samuel\_Sueur](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Samuel\_Sueur](https://forum.inductiveautomation.com/u/Samuel_Sueur)\
**Post date:** [July 14, 2024, 8:21am UTC](https://forum.inductiveautomation.com/t/indirect-query-selection-for-tables-in-ignition-perspective/93191/7 "2024-07-14T08:21:09Z")

</div>

Hi,

If you want to avoid using QueryString and you've already created all your SQL queries, you could do with an expression binding and the runScript function.

Something like this :

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/9/a9270882713a4baefc08baf627d5e8c81e58e21d.png)

The view.custom.dropDownValue is a binding referencing the current value of the dropdown.  
Your dropdown values would have to be "Alarms/Block A/Station/AlarmJournalSta1016", etc etc.

If you have more operations to perform after fetching the data, consider moving the whole script into a script library, and calling the function in the runScript instead.
