# SQLite parameterized syntax for 'WHERE IN ("a", "b", "c")'?

**URL:** <https://discourse.nodered.org/t/sqlite-parameterized-syntax-for-where-in-a-b-c/29349>\
**Category:** General\
**Created:** [2 July 2020 03:12 UTC](https://discourse.nodered.org/t/sqlite-parameterized-syntax-for-where-in-a-b-c/29349 "2020-07-02T03:12:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shimbone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shimbone/32/24815_2.png) [@shimbone](https://discourse.nodered.org/u/shimbone)\
**Post date:** [2 July 2020 03:12 UTC](https://discourse.nodered.org/t/sqlite-parameterized-syntax-for-where-in-a-b-c/29349/1 "2020-07-02T03:12:29Z")

</div>

SELECT \* FROM table  
WHERE field IN ($values)

Does anyone know how a SQLite prepared statement is expecting one to format the $values parameter here? I've tried setting `msg.params.$values` to these strings:

"a", "b"  
'a', 'b'  
a, b

As well as this array:  
["a", "b"]

But none of them work... I'm guessing that something like:

WHERE IN ($valueA, $valueB)

might work. But if the number of items needed in the list varies, that isn't very helpful.

Is there not a way to do this with a prepared statement? Is creating the full SQL string and passing it to the node as `msg.topic` the only way to do this?

Thanks!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 July 2020 10:34 UTC](https://discourse.nodered.org/t/sqlite-parameterized-syntax-for-where-in-a-b-c/29349/2 "2020-07-02T10:34:22Z")

</div>

Did you look at the Info tab on the sqlite node?

```auto
When using Normal or Prepared the query must be entered in the node config.

Pass in the parameters as an object in msg.params for Prepared. Ex:
msg.params = {
    $id:1,
    $name:"John Doe"
}
Parameter object names must match parameters set up in the Prepared Statement. If you get the error SQLITE_RANGE: bind or column index out of range be sure to include $ on the parameter object key.
The sql query for the example above could be: insert into user_table (user_id, user) VALUES ($id, $name);

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 August 2020 10:46 UTC](https://discourse.nodered.org/t/sqlite-parameterized-syntax-for-where-in-a-b-c/29349/3 "2020-08-31T10:46:20Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
