# How to pass WHERE IN \[values for int\] to named query as parameter

**URL:** <https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 13, 2024, 5:07am UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608 "2024-02-13T05:07:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hema\_T](https://avatars.discourse-cdn.com/v4/letter/h/f08c70/32.png) [@Hema\_T](https://forum.inductiveautomation.com/u/Hema_T)\
**Post date:** [February 13, 2024, 5:07am UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608/1 "2024-02-13T05:07:48Z")

</div>

Hi Team,

In one of my application I want to multi select the values in drop down and getting results from database  
here I am using where in (for int ) in named query  
for example :  
I have values like 1,2 here when I pass the values in named query(in where) it takes only 1st given value(1)  
Is there any other ways of how to pass this as a parameter?

THANK YOU

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 13, 2024, 10:32am UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608/2 "2024-02-13T10:32:56Z")

</div>

Answered here:

> [@Ignition Perspective Named Query with WHERE IN Clause](https://forum.inductiveautomation.com/t/ignition-perspective-named-query-with-where-in-clause/34062):
>
> Hello, I need to create a Named Query using WHERE IN a multiple selection on a form. Can this be done? Thanks in advance

---

<div class="post-metadata">

**Author:** ![Hema\_T](https://avatars.discourse-cdn.com/v4/letter/h/f08c70/32.png) [@Hema\_T](https://forum.inductiveautomation.com/u/Hema_T)\
**Post date:** [February 13, 2024, 12:33pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608/3 "2024-02-13T12:33:12Z")

</div>

Hi,  
My db datatype itself int. Hence I need to pass int values as paramater

Thankyou

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 13, 2024, 12:51pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608/4 "2024-02-13T12:51:25Z")

</div>

> [@Hema\_T](#):
>
> My db datatype itself int

Doesn't change the answer. Just don't use quotes in the query string.

A query authored like:

```auto
select someColumn
from someTable
WHERE someColumn IN {someQueryStringParameter}

```

Would then be called like:

```auto
system.db.runNamedQuery('Path/To/SomeNamedQuery',{'someQueryStringParameter':'(1,2,3)'})

```

Note that the parameter is not sanitized and since there are no single quotes included _as part of_ the parameter value, then they will be interpreted as integers in the database.

EDIT: Corrected query example per @pturmel's correction.

---

<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:** [February 13, 2024, 1:26pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608/5 "2024-02-13T13:26:14Z")

</div>

> [@lrose](#):
>
> `IN :someQueryStringParameter`

Not quite. QueryString parameters must be wrapped in curly braces. Leading colon markers are only used with Value parameters.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 13, 2024, 2:16pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608/6 "2024-02-13T14:16:58Z")

</div>

> [@pturmel](#):
>
> QueryString parameters

My avoidance of using them is showing. If I'm writing a Named query and I run into something that can't be handled by any other means, I just use `system.db.runPrepQuery()`.

---

<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:** [February 13, 2024, 2:28pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-where-in-values-for-int-to-named-query-as-parameter/85608/7 "2024-02-13T14:28:53Z")

</div>

> [@lrose](#):
>
> I just use `system.db.runPrepQuery()`.

Concur. Just say **no** to QueryString parameters. Besides, you can [pass arrays to "Prep" queries](https://forum.inductiveautomation.com/t/taking-a-dataset-and-inserting-it-to-a-sql-temp-table/83852/4) if you have a competent database and JDBC drivers.

In this case, the PostgreSQL syntax for `runPrepQuery` would look like this:

```auto
SELECT * FROM some_table WHERE some_column = ANY (?)

```

> **[9.24. Row and Array Comparisons](https://www.postgresql.org/docs/current/functions-comparisons.html#FUNCTIONS-COMPARISONS-ANY-SOME)**
>
> 9.24. Row and Array Comparisons # 9.24.1. IN 9.24.2. NOT IN 9.24.3. ANY/SOME (array) 9.24.4. ALL (array) 9.24.5. Row Constructor Comparison …
