# Bind Named Query Parameter to Tag

**URL:** <https://forum.inductiveautomation.com/t/bind-named-query-parameter-to-tag/62872>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [August 10, 2022, 1:58pm UTC](https://forum.inductiveautomation.com/t/bind-named-query-parameter-to-tag/62872 "2022-08-10T13:58:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwilliams](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jwilliams](https://forum.inductiveautomation.com/u/jwilliams)\
**Post date:** [August 10, 2022, 1:58pm UTC](https://forum.inductiveautomation.com/t/bind-named-query-parameter-to-tag/62872/1 "2022-08-10T13:58:16Z")

</div>

Is it possible in a Named Query to bind a parameter to a tag?

```auto
select job_number as Job, :State as State
from jobs

```

but for each job\_number have the query go to each tag and grab its state?

So say for example a tag looked like this: Job/Job 1/State.value.  
For the first job\_number in the query, 1, it would need to traverse the tag the Job/Job 1/State.value and get that state.value.  
For reference the query would only return integers:

| Job | State |
| --- | --- |
| 1 | 0 |
| 2 | 1 |
| 3 | 0 |

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 10, 2022, 2:20pm UTC](https://forum.inductiveautomation.com/t/bind-named-query-parameter-to-tag/62872/2 "2022-08-10T14:20:42Z")

</div>

> [@jwilliams](#):
>
> Is it possible in a Named Query to bind a parameter to a tag?

Yes.

When you use a Named Query Binding, you can use an expression to set the value of the parameter.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/6/166870bfb556345e3b05b8382f212c94bb3d2775.png)

> [@jwilliams](#):
>
> but for each job\_number have the query go to each tag and grab its state?

This is not possible though, as @pturmel has pointed out.

You'll have to run the query to get data from the database, and then use a script transform (as has been shown in other posts) to add the tag data.

EDIT: Added some clarification.

---

<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 10, 2022, 2:26pm UTC](https://forum.inductiveautomation.com/t/bind-named-query-parameter-to-tag/62872/3 "2022-08-10T14:26:18Z")

</div>

> [@jwilliams](#):
>
> but for each job\_number have the query go to each tag and grab its state?

No. Your database is running the query. It knows nothing about Ignition tags.

---

<div class="post-metadata">

**Author:** ![jwilliams](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jwilliams](https://forum.inductiveautomation.com/u/jwilliams)\
**Post date:** [August 10, 2022, 2:32pm UTC](https://forum.inductiveautomation.com/t/bind-named-query-parameter-to-tag/62872/4 "2022-08-10T14:32:35Z")

</div>

Yeah I see why that wouldn’t work now since the query would not return any data until it has finished executing. Thanks for the clarification @pturmel and @lrose. I’ll have to try a transform to get the additional data I need, just haven’t had any luck with that yet.
