# OPC tag with Queries

**URL:** <https://forum.inductiveautomation.com/t/opc-tag-with-queries/52335>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 26, 2021, 11:38am UTC](https://forum.inductiveautomation.com/t/opc-tag-with-queries/52335 "2021-10-26T11:38:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgonya](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgonya/32/9304_2.png) [@jgonya](https://forum.inductiveautomation.com/u/jgonya)\
**Post date:** [October 26, 2021, 11:38am UTC](https://forum.inductiveautomation.com/t/opc-tag-with-queries/52335/1 "2021-10-26T11:38:03Z")

</div>

I have two OPC tags and a table in a database. I want to use one of the tags to look up on the table the write back on to the other tag.

So, Tag one is Model\_Number, tag two is platfrom

Table date something like this  
id Model\_Number Platform  
1 XXXX0001 YYYY0000  
2 XXXX0002 YYYY0000  
3 XXXX0003 YYYY0001  
4 XXXX0004 YYYY0001  
5 XXXX0005 YYYY0000

The Query will look something like this:

SELECT Platform  
FROM table  
WHERE ModelNum = {Model\_Number}

I want to write back to the PLC with the Platform info that I looked out.  
Read the Model\_Number tag, then write to the Platform tag.  
Read Model\_number = XXXX0001,  
Write Platform = YYYY0000

Is there a way to do this?  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [October 26, 2021, 11:44am UTC](https://forum.inductiveautomation.com/t/opc-tag-with-queries/52335/2 "2021-10-26T11:44:21Z")

</div>

Yep… a transaction group [SQL Bridge (Transaction Groups) - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/pages/viewpage.action?pageId=58597803) might be the easiest way to get this going. But there are a number of other ways you can do this.

---

<div class="post-metadata">

**Author:** ![jgonya](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgonya/32/9304_2.png) [@jgonya](https://forum.inductiveautomation.com/u/jgonya)\
**Post date:** [October 26, 2021, 1:05pm UTC](https://forum.inductiveautomation.com/t/opc-tag-with-queries/52335/3 "2021-10-26T13:05:52Z")

</div>

Thanks for the info and based on the manual this would work nicely.  
However, I can’t seem to get it to work. Manual not really helping nor the videos. I keep getting an error with the expression item. Here the query:  
SELECT Platform  
FROM table  
WHERE  
ModelNum = {[~]ModelNum}

It comes back with “Invalid column name ‘XXXX0001’.” So for whatever reason it looking for the tag data as a column name.  
I going to keep trying to figure it out.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [October 26, 2021, 1:08pm UTC](https://forum.inductiveautomation.com/t/opc-tag-with-queries/52335/4 "2021-10-26T13:08:54Z")

</div>

If you can post a picture of your transaction group so we can take a look at how you are setting it up.

---

<div class="post-metadata">

**Author:** ![jgonya](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgonya/32/9304_2.png) [@jgonya](https://forum.inductiveautomation.com/u/jgonya)\
**Post date:** [October 26, 2021, 1:23pm UTC](https://forum.inductiveautomation.com/t/opc-tag-with-queries/52335/5 "2021-10-26T13:23:31Z")

</div>

I just got it. Thanks for the info.
