# DropDown List SQL Query Binding Question

**URL:** <https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722>\
**Category:** Ignition\
**Tags:** ignition81, database, vision\
**Created:** [August 13, 2025, 10:17pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722 "2025-08-13T22:17:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![McLendon\_Automation](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mclendon_automation/32/78325_2.png) [@McLendon\_Automation](https://forum.inductiveautomation.com/u/McLendon_Automation)\
**Post date:** [August 13, 2025, 10:17pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/1 "2025-08-13T22:17:12Z")

</div>

I have used the following SQL Query Binding in many DropDown List Components (In Vision) to populate the DropDown List (Data) for user selection. The project I am currently working on is Ignition Version 8.1.48

 ![DropDown Data Binding that does not work in ver8_1_48](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/0/40ddc4ed9b0f56eb6b96fe918ccd1121ac95c8ba.png)

I get the following error msg when using it now.

 ![Dropdown Vision Query Binding ErrorMSG](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/4/84b77139a12ffe1260dc3f36b211cf146498ffb7.png)

I am curious why this worked in older versions and now does not seem to function. Or what did I miss that would make this binding function?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 13, 2025, 10:21pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/2 "2025-08-13T22:21:27Z")

</div>

Whatever table you are selecting from doesn’t have a column called `No Selection`. If you are trying to just have ‘No Selection’ as text in the second column, wrap it in single quotes `’ ’`. Double quotes `” “` in SQL denote identifiers, such as table or column names.

---

<div class="post-metadata">

**Author:** ![McLendon\_Automation](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mclendon_automation/32/78325_2.png) [@McLendon\_Automation](https://forum.inductiveautomation.com/u/McLendon_Automation)\
**Post date:** [August 13, 2025, 10:30pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/3 "2025-08-13T22:30:59Z")

</div>

I tried the single quotes → ‘No Selection’ and then received the following error msg.

 ![Dropdown Vision Query Binding ErrorMSG2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b952b32411788686b6fd76d903002f4f8a3c01de.png)

This isn’t currently affecting the project I am working on it is just an annoyance since it has worked for me so many times before. I did realize that I am now working with SQL Server and all me previous projects were in MySQL. Could that be the difference?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 13, 2025, 10:36pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/4 "2025-08-13T22:36:16Z")

</div>

> [@McLendon\_Automation](#):
>
> previous projects were in MySQL

Possibly, I don’t know how closely MySQL follows the spec.

In MSSQL, UNIONs require the columns in the same positions to be similar types. Try casting batch to a NVARCHAR in the ‘Label’ column

try  
`SELECT batch as Value, CAST(batch as nvarchar) as Label`  
instead of  
`SELECT batch as Value, batch as Label`

Edit: Just looked it up, MySQL appears to allow double quotes to be used to denote strings, and uses back quotes to denote identifiers.

> **[MySQL :: MySQL 8.4 Reference Manual :: 11.1.1 String Literals](https://dev.mysql.com/doc/refman/8.4/en/string-literals.html)**

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [August 13, 2025, 10:43pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/5 "2025-08-13T22:43:26Z")

</div>

MySQL has more standard syntax, MSSQL has customised and made so much of its query language non-standard that it’s very time consuming switching a nice working Ignition project between the two. Postgres to MySQL is a couple of minutes normally.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 13, 2025, 10:46pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/6 "2025-08-13T22:46:46Z")

</div>

> [@David\_Stone](#):
>
> MySQL has more standard syntax, MSSQL has customised

This is true for the majority of stuff, but even Postgres uses double quotes for identifiers, so looks like MySQL is the odd one out here in this case.

> **[4.1. Lexical Structure](https://www.postgresql.org/docs/current/sql-syntax-lexical.html)**
>
> 4.1. Lexical Structure # 4.1.1. Identifiers and Key Words 4.1.2. Constants 4.1.3. Operators 4.1.4. Special Characters 4.1.5. Comments 4.1.6. Operator Precedence …

> There is a second kind of identifier: the _delimited identifier_ or _quoted identifier_. It is formed by enclosing an arbitrary sequence of characters in double-quotes (`"`). A delimited identifier is always an identifier, never a key word.

---

<div class="post-metadata">

**Author:** ![McLendon\_Automation](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mclendon_automation/32/78325_2.png) [@McLendon\_Automation](https://forum.inductiveautomation.com/u/McLendon_Automation)\
**Post date:** [August 13, 2025, 10:53pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/7 "2025-08-13T22:53:26Z")

</div>

> [@ryan.white](#):
>
> Possibly, I don’t know how closely MySQL follows the spec.
> 
> In MSSQL, UNIONs require the columns in the same positions to be similar types. Try casting batch to a NVARCHAR in the ‘Label’ column
> 
> try  
> `SELECT batch as Value, CAST(batch as nvarchar) as Label`  
> instead of  
> `SELECT batch as Value, batch as Label`
> 
> Edit: Just looked it up, MySQL appears to allow double quotes to be used to denote strings, and uses back quotes to denote identifiers.

This makes sense now. After changing the double quote “No Selection” to single quotes, ‘No Selection’ I jumped to the conclusion that the error was still flagging the ‘No Selection’ part of the query. I tried Cast(batch as nvarchar) AS Label and received the same error msg, converting varchar to bigint. Here is another wrinkle in my first question. The SQL Query that is installed and currently functioning is the following →

 ![Dropdown Data Binding query](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/45237e24ea8b3d77f167ad5912f2a694b6733054.png)

Why does this one convert the bigint to varchar and as soon as I try to display some defaults like the UNION with the ‘%"‘ and ‘No Selection’ throw an error?

I’m an old man and learning new things is still fun.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 13, 2025, 11:05pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/8 "2025-08-13T23:05:11Z")

</div>

> [@McLendon\_Automation](#):
>
> Why does this one convert the bigint to varchar

Technically in the simpler SQL, the SQL is NOT converting anything to nvarchar. The data is being provided back as BIGINT, and java(Ignition) uses it as such. There might be some java stringify happening to make the selected label value in the dropdown a string, but that’s all on Ignition side.

Regarding the Union, I just realized you need to cast BOTH columns as NVARCHAR. `%` is not a valid integer value. So you would need: `SELECT CAST(batch as nvarchar) as Value, CAST(batch as nvarchar) as Label`

I’m guessing MySQL would look at the union columns and determines which type worked for both columns, hence no explicit casting.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 13, 2025, 11:15pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/9 "2025-08-13T23:15:11Z")

</div>

The SQL standard calls for double quotes around identifiers, and single quotes around values.

Out of the box, MSSQL and MySQL and MariaDB use other characters for identifier quotes, but can be configured to use double quotes. PostgreSQL and Oracle follow the standard.

---

<div class="post-metadata">

**Author:** ![McLendon\_Automation](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mclendon_automation/32/78325_2.png) [@McLendon\_Automation](https://forum.inductiveautomation.com/u/McLendon_Automation)\
**Post date:** [August 13, 2025, 11:15pm UTC](https://forum.inductiveautomation.com/t/dropdown-list-sql-query-binding-question/109722/10 "2025-08-13T23:15:40Z")

</div>

> [@ryan.white](#):
>
> Technically in the simpler SQL, the SQL is NOT converting anything to nvarchar. The data is being provided back as BIGINT, and java(Ignition) uses it as such. There might be some java stringify happening to make the selected label value in the dropdown a string, but that’s all on Ignition side.
> 
> Regarding the Union, I just realized you need to cast BOTH columns as NVARCHAR. `%` is not a valid integer value. So you would need: `SELECT CAST(batch as nvarchar) as Value, CAST(batch as nvarchar) as Label`
> 
> I’m guessing MySQL would look at the union columns and determines which type worked for both columns, hence no explicit casting.

Thanks again ryan.white

I appreciate your help. I only have three customers that use ignition and sometimes I have long periods where I don’t get to work with it. I’m just old enough that I forget… everthing.
