# Using update, Insert and select query in a single named query on same database

**URL:** <https://forum.inductiveautomation.com/t/using-update-insert-and-select-query-in-a-single-named-query-on-same-database/99402>\
**Category:** Ignition\
**Tags:** perspective, namedqueries\
**Created:** [December 4, 2024, 7:39am UTC](https://forum.inductiveautomation.com/t/using-update-insert-and-select-query-in-a-single-named-query-on-same-database/99402 "2024-12-04T07:39:38Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Lynn\_Martineau](https://avatars.discourse-cdn.com/v4/letter/l/f1d935/32.png) [@Lynn\_Martineau](https://forum.inductiveautomation.com/u/Lynn_Martineau)\
**Post date:** [December 4, 2024, 2:00pm UTC](https://forum.inductiveautomation.com/t/using-update-insert-and-select-query-in-a-single-named-query-on-same-database/99402/6 "2024-12-04T14:00:11Z")

</div>

Take a look at the MERGE command for your database.  
e.g. [SQL Server MERGE](https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=sql-server-ver16)  
That will give you either INSERT or UPDATE but take a look at the reference posted by @Transistor; With NamedQueries, you need to choose between `Query` and `Update Query`; you won't be able to cross that line.

As a personal preference, I create folders (SELECT, INSERT, UPDATE, DELETE) and create a NamedQuery of the table name I'm working with inside each folder. That way, calling a NamedQuery it feels more natural and SQL like as well as providing a little self-documentation of what you are doing when you call:

- SELECT/TableName
- INSERT/TableName
- UPDATE/TableName

---

_[View the full topic](https://forum.inductiveautomation.com/t/using-update-insert-and-select-query-in-a-single-named-query-on-same-database/99402)._
