# Using tags inside SQL WHERE clause in Memory Tags

**URL:** <https://forum.inductiveautomation.com/t/using-tags-inside-sql-where-clause-in-memory-tags/53858>\
**Category:** Ignition\
**Created:** [December 7, 2021, 8:10pm UTC](https://forum.inductiveautomation.com/t/using-tags-inside-sql-where-clause-in-memory-tags/53858 "2021-12-07T20:10:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexZanduR](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alexzandur/32/31297_2.png) [@AlexZanduR](https://forum.inductiveautomation.com/u/AlexZanduR)\
**Post date:** [December 7, 2021, 8:10pm UTC](https://forum.inductiveautomation.com/t/using-tags-inside-sql-where-clause-in-memory-tags/53858/1 "2021-12-07T20:10:42Z")

</div>

Getting syntax error when trying to test Memory Tag. Not sure how I can call the tag in the WHERE clause.

_**ERROR\_ExpressionEval(“ERROR: syntax error at or near “05” Position: 91”)**_

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

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

---

<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:** [December 7, 2021, 8:13pm UTC](https://forum.inductiveautomation.com/t/using-tags-inside-sql-where-clause-in-memory-tags/53858/2 "2021-12-07T20:13:34Z")

</div>

An expression error is a hint that you are using the wrong kind of binding or tag type for SQL. SQL bindings don’t yield _ **expression** _ errors.

Also note that curly braces in simple queries perform stringification and then string substitution into the query text. That is almost certainly going to yield invalid syntax for datetime types without value quotes. That is something that should be a named query parameter.

---

<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:** [December 7, 2021, 8:15pm UTC](https://forum.inductiveautomation.com/t/using-tags-inside-sql-where-clause-in-memory-tags/53858/3 "2021-12-07T20:15:29Z")

</div>

Also, I doubt your “FILTER” clause is syntactically valid. Just include the extra condition in the WHERE clause.

---

<div class="post-metadata">

**Author:** ![AlexZanduR](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alexzandur/32/31297_2.png) [@AlexZanduR](https://forum.inductiveautomation.com/u/AlexZanduR)\
**Post date:** [December 7, 2021, 8:20pm UTC](https://forum.inductiveautomation.com/t/using-tags-inside-sql-where-clause-in-memory-tags/53858/4 "2021-12-07T20:20:31Z")

</div>

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