# Why there is a Query Type in named queries?

**URL:** <https://forum.inductiveautomation.com/t/why-there-is-a-query-type-in-named-queries/96110>\
**Category:** Ignition\
**Tags:** ignition81, namedqueries\
**Created:** [September 18, 2024, 9:38am UTC](https://forum.inductiveautomation.com/t/why-there-is-a-query-type-in-named-queries/96110 "2024-09-18T09:38:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [September 18, 2024, 9:38am UTC](https://forum.inductiveautomation.com/t/why-there-is-a-query-type-in-named-queries/96110/1 "2024-09-18T09:38:49Z")

</div>

Hello!

Asking from the ignorance.

Why does exists the `Query Type` in the named queries?

I mean, I understand what does each type, but why not simply delete the query type and make all the queries work always?

Any explanation about this would be grateful.  
I repeat, asking from the ignorance, I simply wanna learn more about Ignition and how it works.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [September 18, 2024, 9:46am UTC](https://forum.inductiveautomation.com/t/why-there-is-a-query-type-in-named-queries/96110/2 "2024-09-18T09:46:02Z")

</div>

I add screenshot for reference  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/5654b167eed4c0507c13a9bf9fe8ff437bb394ef.png)

Got some info:

1. **Query** : A general-purpose query used to retrieve data from a database. This typically involves SELECT statements that return multiple rows and columns of data.
2. **Scalar Query** : A query that returns a single value or a scalar result, usually from an aggregation or a specific field in the database. For instance, a query that returns the count of rows, the maximum value, or a single specific record falls into this category.
3. **Update Query** : A query used to modify existing data in the database. This usually involves executing UPDATE, DELETE, or INSERT commands to change the state of the data in the database.

These options allow users to choose the appropriate type of query depending on whether they need to retrieve data, perform calculations, or update records.

For instance, retrieving a single scalar value can be optimized differently from retrieving a large dataset. The system can apply appropriate optimizations based on the type selected.

May apply stricter controls to **Update Queries** because they change the data. By separating them, it's easier to manage permissions and ensure that only authorized users can perform certain types of operations.

I guess having these options also is easier for the user to define what he want to archieve

---

<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:** [September 18, 2024, 1:33pm UTC](https://forum.inductiveautomation.com/t/why-there-is-a-query-type-in-named-queries/96110/3 "2024-09-18T13:33:02Z")

</div>

JDBC, the Java database connection API, distinguishes between "updates" and "queries", and they must be run with different Java code "under the hood". It's difficult to reliably auto-detect whether a given bit of SQL string is an update or a query, so we don't even try, and rely on what you tell us.
