# Query Tag Error

**URL:** <https://forum.inductiveautomation.com/t/query-tag-error/18899>\
**Category:** Ignition\
**Created:** [July 19, 2018, 6:36pm UTC](https://forum.inductiveautomation.com/t/query-tag-error/18899 "2018-07-19T18:36:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [July 19, 2018, 6:36pm UTC](https://forum.inductiveautomation.com/t/query-tag-error/18899/1 "2018-07-19T18:36:06Z")

</div>

Can somebody please tell why in the world this query tag isn’t working? I’m stumped.

```auto
SELECT quantity
FROM mill_workorders
WHERE po = {[.]ReportPO} and style = {[.]ReportStyle}

```

`Error evaluating tag: Unknown column '0731514KP' in 'where clause'`

the 0731514KP is the tag value for ReportStyle, which isn’t a column in the db, style is the column. Why does it think the tag is the column name and not style? the po condition works fine. So confused…

---

<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:** [July 19, 2018, 6:39pm UTC](https://forum.inductiveautomation.com/t/query-tag-error/18899/2 "2018-07-19T18:39:28Z")

</div>

Try:

```sql
SELECT quantity
FROM mill_workorders
WHERE po = {[.]ReportPO} and style = '{[.]ReportStyle}'

```

Query tags fill in values directly, _before_ sending the query to the DB, so your statement is getting sent to the database as:

```sql
SELECT quantity
FROM mill_workorders
WHERE po = 12345 and style = 0731514KP

```

The PO probably works because it’s a number, which SQL doesn’t require you to escape - but it thinks you’re referring to another column with `0731514KP` because it’s not wrapped in single quotes.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [July 19, 2018, 6:42pm UTC](https://forum.inductiveautomation.com/t/query-tag-error/18899/3 "2018-07-19T18:42:47Z")

</div>

I thought about that, but I figured it would try to match it as literally “{[.]ReportStyle}” instead of the tag value, but I guess that’s what the {} are for. Thanks

---

<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:** [January 4, 2021, 6:06pm UTC](https://forum.inductiveautomation.com/t/query-tag-error/18899/4 "2021-01-04T18:06:21Z")

</div>

A post was split to a new topic: [Query tag issue](https://forum.inductiveautomation.com/t/query-tag-issue/41939)
