# Creating a Custom Table update/select

**URL:** <https://forum.inductiveautomation.com/t/creating-a-custom-table-update-select/1805>\
**Category:** Ignition\
**Created:** [May 5, 2010, 3:16pm UTC](https://forum.inductiveautomation.com/t/creating-a-custom-table-update-select/1805 "2010-05-05T15:16:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kacarmich](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@kacarmich](https://forum.inductiveautomation.com/u/kacarmich)\
**Post date:** [May 5, 2010, 3:16pm UTC](https://forum.inductiveautomation.com/t/creating-a-custom-table-update-select/1805/1 "2010-05-05T15:16:39Z")

</div>

I have a table with data from multiple machines, and want to update the last row of the table for a particular machine with a group. I tried creating an sql tag called “A055\_Down\_Last\_ndx” with the following expression:  
SELECT max(ndx)from Machine\_Data where (Machine\_Name)=‘A055’  
The idea was to find the last index for that machine, however I get an error for this tag and a null value.  
Then I was planning on using the custom option in the table update/select, and entering the following in the field:  
(ndx)={A055\_Down\_Last\_ndx}

Any suggestions on better methods would be appreciated.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 5, 2010, 4:05pm UTC](https://forum.inductiveautomation.com/t/creating-a-custom-table-update-select/1805/2 "2010-05-05T16:05:59Z")

</div>

Why don’t you use transaction groups? Updating the last row of the table is a built-in feature of the Standard Group…

Your method will work - your error was probably just a syntax error. Also -you said you used that query as an expression. Did you have the tag correctly set to SQL Query mode instead of expression mode?

---

<div class="post-metadata">

**Author:** ![kacarmich](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@kacarmich](https://forum.inductiveautomation.com/u/kacarmich)\
**Post date:** [May 5, 2010, 4:55pm UTC](https://forum.inductiveautomation.com/t/creating-a-custom-table-update-select/1805/3 "2010-05-05T16:55:23Z")

</div>

I needed to use a custom table update/select because there are several machines logging to the same table during this transaction, so I need to find the last transaction for the particular machine that the group is tied to.  
The problem ended up being that I did not have the Realtime SQLTags Providers pointed to my database.

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [May 5, 2010, 7:09pm UTC](https://forum.inductiveautomation.com/t/creating-a-custom-table-update-select/1805/4 "2010-05-05T19:09:01Z")

</div>

You could probably do this all directly in the group’s Where clause, no tag required:  
Update Custom Where

```auto
ndx = (SELECT max(ndx) from Machine_Data where (Machine_Name)='A055')
```
