# SQL Select Scripting Question

**URL:** <https://forum.inductiveautomation.com/t/sql-select-scripting-question/8588>\
**Category:** Ignition\
**Created:** [June 18, 2014, 10:20pm UTC](https://forum.inductiveautomation.com/t/sql-select-scripting-question/8588 "2014-06-18T22:20:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ceccontrols](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@ceccontrols](https://forum.inductiveautomation.com/u/ceccontrols)\
**Post date:** [June 18, 2014, 10:20pm UTC](https://forum.inductiveautomation.com/t/sql-select-scripting-question/8588/1 "2014-06-18T22:20:27Z")

</div>

What is the syntax in the select statement to allow the query to check for Product\_ID = the value of the Totalscan variable and not look for the text “Totalscan”

###Convert scanner bar code bytes to ASCII and combine into a single string  
Totalscan = unichr(w3b1)+ unichr(w3b2) + unichr(w4b1) + unichr(w4b2) + unichr(w5b1) + unichr(w5b2) + unichr(w6b1) + unichr(w6b2)

myvalue = system.db.runScalarQuery(“select Rectifier\_1\_Voltage from Rectifier\_Settings where Product\_ID = Totalscan”)

java.lang.Exception: java.lang.Exception: Error executing system.db.runScalarQuery(select Rectifier\_1\_Voltage from Rectifier\_Settings where Product\_ID = Totalscan, MyDB, , )

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 18, 2014, 10:27pm UTC](https://forum.inductiveautomation.com/t/sql-select-scripting-question/8588/2 "2014-06-18T22:27:04Z")

</div>

```auto
myvalue = system.db.runScalarQuery("select Rectifier_1_Voltage from Rectifier_Settings where Product_ID = '%s'"%Totalscan)
```

---

<div class="post-metadata">

**Author:** ![ceccontrols](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@ceccontrols](https://forum.inductiveautomation.com/u/ceccontrols)\
**Post date:** [June 19, 2014, 1:16pm UTC](https://forum.inductiveautomation.com/t/sql-select-scripting-question/8588/3 "2014-06-19T13:16:20Z")

</div>

Worked perfectly!
