# SQL query with table/row/value where clause

**URL:** <https://forum.inductiveautomation.com/t/sql-query-with-table-row-value-where-clause/11073>\
**Category:** Ignition\
**Created:** [January 20, 2016, 4:45pm UTC](https://forum.inductiveautomation.com/t/sql-query-with-table-row-value-where-clause/11073 "2016-01-20T16:45:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boster281](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@boster281](https://forum.inductiveautomation.com/u/boster281)\
**Post date:** [January 20, 2016, 4:45pm UTC](https://forum.inductiveautomation.com/t/sql-query-with-table-row-value-where-clause/11073/1 "2016-01-20T16:45:38Z")

</div>

I want to use a container value from the selected table row as a where clause in the component scripting sql update query when I press a button.

queryValue = ‘520’  
qv1 = event.source.parent.getComponent(‘Group 1’).getComponent(‘Table’).selectedRow  
system.db.runUpdateQuery(“UPDATE FinishingResults SET Suspect = %s WHERE Container = %s” % (queryValue, qv1), ‘Thermoplastics’)

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [January 20, 2016, 5:37pm UTC](https://forum.inductiveautomation.com/t/sql-query-with-table-row-value-where-clause/11073/2 "2016-01-20T17:37:14Z")

</div>

You will need to get the value from the dataset, not just the selectedRow.

`table = event.source.parent.getComponent('Group 1').getComponent('Table')
qv1 = table.data.getValueAt(table.selectedRow, "Container")`

---

<div class="post-metadata">

**Author:** ![boster281](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@boster281](https://forum.inductiveautomation.com/u/boster281)\
**Post date:** [January 20, 2016, 5:44pm UTC](https://forum.inductiveautomation.com/t/sql-query-with-table-row-value-where-clause/11073/3 "2016-01-20T17:44:07Z")

</div>

This worked great. Thanks
