# Can I reference the name of a query tag in the query?

**URL:** <https://forum.inductiveautomation.com/t/can-i-reference-the-name-of-a-query-tag-in-the-query/85630>\
**Category:** Ignition Exchange\
**Created:** [February 13, 2024, 2:25pm UTC](https://forum.inductiveautomation.com/t/can-i-reference-the-name-of-a-query-tag-in-the-query/85630 "2024-02-13T14:25:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Sommerville](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Chris\_Sommerville](https://forum.inductiveautomation.com/u/Chris_Sommerville)\
**Post date:** [February 13, 2024, 2:25pm UTC](https://forum.inductiveautomation.com/t/can-i-reference-the-name-of-a-query-tag-in-the-query/85630/1 "2024-02-13T14:25:21Z")

</div>

I want to create a set of query tags for different machines at my facility.  
If I named the query tags, for example, "23" to represent that it's for machine 23, is there a way to reference the name "23" in the following scenario:

Select \*  
From query  
Where machine = **[Query Tag Name]**

So that when I copy and duplicate the tag, it automatically updates without me having to go into each individual query tag to adjust this value?

---

<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:** [February 13, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/can-i-reference-the-name-of-a-query-tag-in-the-query/85630/2 "2024-02-13T14:57:21Z")

</div>

Try,

```sql
SELECT *
FROM tableName
WHERE machine = {this.name}

```

I can't test it at the moment but it works in expression tags.

---

<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:** [February 13, 2024, 3:00pm UTC](https://forum.inductiveautomation.com/t/can-i-reference-the-name-of-a-query-tag-in-the-query/85630/3 "2024-02-13T15:00:54Z")

</div>

> [@Chris\_Sommerville](#):
>
> set of query tags for different machines at my facility.

This is really bad for your database, unless the queries are parameterized, use event driven mode, and therefore only run occassionally.

If you need to run these regularly, use a timer or scheduled event. Its script would read all the machines in one query, split into subsets, and write the subsets to tags. Your database admin will appreciate it.
