# SQL Lookup Table

**URL:** <https://forum.inductiveautomation.com/t/sql-lookup-table/110841>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 22, 2025, 4:42pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841 "2025-09-22T16:42:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 22, 2025, 4:42pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/1 "2025-09-22T16:42:00Z")

</div>

I am trying to create a lookup table that is linked to my SQL database. I have a database where part stats are saved. I want to be able to search a specific work order and see that parts that are in the work order and see specific stats about each part and I want to see cumulative stats (fail rate, total parts, stuff like that).

I am not sure the best/most efficient way to do this. I saw another topic about potentially using a python script, but I feel like there is a better way to do this.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 22, 2025, 4:49pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/2 "2025-09-22T16:49:29Z")

</div>

Scripting is never the most efficient way. Use a Named Query binding on a Table.

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 22, 2025, 4:54pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/3 "2025-09-22T16:54:17Z")

</div>

I saw there was the option but my database isn’t showing up. I’m sure I’m doing something wrong but I don’t know what

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 22, 2025, 4:56pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/4 "2025-09-22T16:56:20Z")

</div>

You need to create a named query first - do you have (saved) named queries in your current project?

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 22, 2025, 4:57pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/5 "2025-09-22T16:57:31Z")

</div>

I do not

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 22, 2025, 5:00pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/6 "2025-09-22T17:00:06Z")

</div>

Okay, so you'll need to create a named query and add a parameter to it for your work order:

> **[Named Query Introduction Video at Inductive University](https://inductiveuniversity.com/videos/named-query-introduction/8.3)**
>
> Take a quick tour of the Named Query workspace.

> **[Named Query Parameters Video at Inductive University](https://inductiveuniversity.com/videos/named-query-parameters/8.3)**
>
> In this lesson, learn how to add both Value and QueryString parameters to a Named Query.

Then you'll be able to select that in the Perspective binding and link the query parameter to some property on your view.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 22, 2025, 5:47pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/7 "2025-09-22T17:47:30Z")

</div>

And, just in case you haven't realised it yet, the first thing you need to do is create a database connection.

> **[Database Connections | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/database-connections)**
>
> How are Databases Used in Ignition?

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 22, 2025, 6:10pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/8 "2025-09-22T18:10:02Z")

</div>

I now have it all setup so I can pull in data from my SQL and display it in a table. I still have another question though. How do I map a query parameter to a input box? I want to let the user type in a workorder and see all the parts from that work order

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 22, 2025, 6:16pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/9 "2025-09-22T18:16:37Z")

</div>

That's what Paul's second video link demonstrates. [Named Query Parameters Video at Inductive University](https://inductiveuniversity.com/videos/named-query-parameters/8.3).

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 22, 2025, 6:25pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/10 "2025-09-22T18:25:15Z")

</div>

I see that I can use the QueryString to create a dynamic parameter. I just don’t know how to link that QueryString to the numeric entry field I have

---

<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:** [September 22, 2025, 6:27pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/11 "2025-09-22T18:27:30Z")

</div>

> [@bshriner](#):
>
> I can use the QueryString to create a dynamic parameter

You **can** , but generally should **not** , as it permits SQL injection from user input. Use **value** parameters.

(Show your NQ SQL, formatted as code, for more specific help.)

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 22, 2025, 6:28pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/12 "2025-09-22T18:28:19Z")

</div>

1. Create a custom view property to capture the user input.
2. Create a Property binding on the input value that references the custom property and check the `Bidirectional` checkbox.
3. Pass the custom view property as a parameter to your named query by clicking on the _`fx`_ in the parameter box:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0bd6f4b80565e10118b45a4f82f2c307e47e1d68.png)

You _can_ pass the value of the input directly as a parameter to the query, but I don't recommend this, as the reference can break if you ever rearrange the component layout holding that input (or the table the query is bound to).

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 22, 2025, 6:34pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/13 "2025-09-22T18:34:02Z")

</div>

Understand this, from [Named Query Parameters | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/sql-in-ignition/named-queries/named-query-parameters#types-of-named-query-parameters:)

> The **Value** type should be used whenever a Named Query needs **a dynamic WHERE clause**. These act like values passed to a prepared statement, meaning they can never be used to parameterize column or table names. However, **they are resilient to SQL injection attacks**.

Example:

```python
SELECT * 
FROM mytable
WHERE name = :myParam

```

> **QueryStrings** are more flexible than the Value type in that they can be used to parameterize **column** and **table names**. However, their values are never sanitized, which causes them to be **more susceptible to SQL injection attacks**. When using QueryStrings, it is best to avoid situations where the user can manually type in the value that will be passed to the Name Query.

Example:

```python
SELECT {myColumnName} 
FROM mytable
WHERE ...

```

---

<div class="post-metadata">

**Author:** ![bshriner](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bshriner](https://forum.inductiveautomation.com/u/bshriner)\
**Post date:** [September 22, 2025, 6:43pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/14 "2025-09-22T18:43:27Z")

</div>

Where do I create this custom view property?

Sorry for all the questions. I am very new to Ignition and how to navigate everything.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 22, 2025, 6:48pm UTC](https://forum.inductiveautomation.com/t/sql-lookup-table/110841/15 "2025-09-22T18:48:28Z")

</div>

Custom properties are created in the panel on the right:

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

Just make sure you have the view itself selected, not the root or any other component within it (you _can_ create custom properties for those, but I don't recommend it, for the reason I stated about relative references potentially breaking when you rearrange components).
