# CTE's in Ignition SQL Queries throwing update errors

**URL:** <https://forum.inductiveautomation.com/t/ctes-in-ignition-sql-queries-throwing-update-errors/65685>\
**Category:** Ignition\
**Tags:** database\
**Created:** [October 25, 2022, 10:00pm UTC](https://forum.inductiveautomation.com/t/ctes-in-ignition-sql-queries-throwing-update-errors/65685 "2022-10-25T22:00:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hayes\_Bentley](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@Hayes\_Bentley](https://forum.inductiveautomation.com/u/Hayes_Bentley)\
**Post date:** [October 25, 2022, 10:00pm UTC](https://forum.inductiveautomation.com/t/ctes-in-ignition-sql-queries-throwing-update-errors/65685/1 "2022-10-25T22:00:58Z")

</div>

Is there limited functionality writing SQL queries using CTE's? Whenever I use CTE's, Ignition thinks I am trying to run an update statement, when in actuality I am trying to access data in my CTE. Thanks!

---

<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:** [October 25, 2022, 10:26pm UTC](https://forum.inductiveautomation.com/t/ctes-in-ignition-sql-queries-throwing-update-errors/65685/2 "2022-10-25T22:26:22Z")

</div>

Some parts of Ignition (like the designer's query browser) have to guess what kind of statement you've given it. The guess is super-lame--I think it just looks for "SELECT" before other keywords. No help for that in the query browser. Most other parts of Ignition the type of query is implied by the function name or is settable in the local properties (named queries, query tags).

---

<div class="post-metadata">

**Author:** ![Hayes\_Bentley](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@Hayes\_Bentley](https://forum.inductiveautomation.com/u/Hayes_Bentley)\
**Post date:** [October 26, 2022, 12:50pm UTC](https://forum.inductiveautomation.com/t/ctes-in-ignition-sql-queries-throwing-update-errors/65685/3 "2022-10-26T12:50:31Z")

</div>

Thanks for the quick response, I was using the query browser! Do you think running a query with CTE using system.db.runQuery in a script would be fine? My goal is to populate a dataset tag with the results of my query based on a user entered ID.

---

<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:** [October 26, 2022, 1:03pm UTC](https://forum.inductiveautomation.com/t/ctes-in-ignition-sql-queries-throwing-update-errors/65685/4 "2022-10-26T13:03:33Z")

</div>

> [@Hayes\_Bentley](#):
>
> Do you think running a query with CTE using system.db.runQuery in a script would be fine?

Yes, should. You can try that in the Designer's script console. Place the SQL in a triple-quoted jython string block to keep your formatting.
