Couchbase N1QL WHERE…IN

Eli Segev
1 min readAug 21, 2019

Couchbase query language N1QL is very annoying when it comes to WHERE...IN clause. I find it very odd that it decided to go different than RBDMS SQL queries, and require square brackets ["value1", "value2"] instead of the round brackets that are so common pretty much in every tool (and for DB people: in RDBMS SQL).

A full functioning example for Couchbase N1QL:

SELECT fields FROM bucket WHERE field IN ["value1", "value2", ...]

And the following example will not work:

SELECT fields FROM bucketWithBadQuery WHERE fieldWithBadWhere IN ("value1", "value2", ...)

By the way, I came across this when I tried doing a nice query that additionally doesSELECT COUNT(*) ... GROUP BY field and SELECT parentNode.field FROM bucket UNNEST bucket.parentNode AS parentNode for the first time, and integrating all those clauses together needed some extra effort.

--

--