# Mixing IN operator with SQL database and arrays

**URL:** <https://talk.observablehq.com/t/mixing-in-operator-with-sql-database-and-arrays/10275>\
**Category:** Help\
**Created:** [February 24, 2025, 11:16am UTC](https://talk.observablehq.com/t/mixing-in-operator-with-sql-database-and-arrays/10275 "2025-02-24T11:16:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliviermilla](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/oliviermilla/32/9484_2.png) [@oliviermilla](https://talk.observablehq.com/u/oliviermilla)\
**Post date:** [February 24, 2025, 11:16am UTC](https://talk.observablehq.com/t/mixing-in-operator-with-sql-database-and-arrays/10275/1 "2025-02-24T11:16:14Z")

</div>

Hello,

I’ve followed the step described in [Mixing Queries and Arrays into SQL / Observable | Observable](https://observablehq.com/@observablehq/mix-queries-and-arrays-into-sql) to get a query with a IN operator working:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/4/4c4176cc8a65672c388a3001c3ea3f60df0eba54.png)

then using `selectedFundInstitRetail` in a SQL query running on Snowflake:

```sql
SELECT
...LONG...LIST...
FROM SNOWFLAKE
WHERE COLUMN_IN_QUESTION IN (${selectedFundInstitRetail})

```

Here comes the funny part:

- When I select both `Institutional` and `Retail`, I only get Institutional in the results.
- When I select only `Institutional`, I only get Institutional in the results.
- When I select only `Retail`, I only get Retail in the results.

In short, one could say that the interpolation only uses the FIRST value of the array.

I tried to work around by separating the stuffs:

1. Remove the WHERE clause in the above query.
2. Create a new SQL Cell, with the above query as the source.
3. Try applying the WHERE clause in there.

This yields the error:

`Error: Invalid column type encountered for argument 0`.

Which I don’t get. Indeed that means I’m querying a JS Object “as if” a SQL database. But I understood that was a super-trick of Observable. 🙂

Thx for your Help.

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [February 24, 2025, 9:22pm UTC](https://talk.observablehq.com/t/mixing-in-operator-with-sql-database-and-arrays/10275/2 "2025-02-24T21:22:11Z")

</div>

That sounds like it’s dropping everything after the first array item which happens in vanilla Snowflake connectors if you pass arrays. Make sure you define a new data source in your notebook through `extendDB(...)`, and to select that source in your SQL cell.

You can verify that the arguments get passed through correctly by running the following query:

```sql
select ${["foo", "bar"]}

```

* * *

For future reference, here’s a list of how the various clients handle arrays by default:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/6/6087700f122665114b20edde9a898bd186375152.png)

---

<div class="post-metadata">

**Author:** ![oliviermilla](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/oliviermilla/32/9484_2.png) [@oliviermilla](https://talk.observablehq.com/u/oliviermilla)\
**Post date:** [February 25, 2025, 8:49am UTC](https://talk.observablehq.com/t/mixing-in-operator-with-sql-database-and-arrays/10275/3 "2025-02-25T08:49:08Z")

</div>

Thank you @mootari !
