Reputation: 39179
I'm having some trouble wrapping my head around querying JSON arrays in postgres. For example:
Given a Postgres table foobar
with the JSONB column data
like...
db=# select * from foobar;
id | data
----+--------------------------------------------
1 | [[true, true], [true, false]]
2 | [[true, true], [true, true]]
3 | [[true, true], [true, true], [true, true]]
(3 rows)
How would I write a select query that would select only the row which contains only true
values in each array in data
and whose array is of length 2. (i.e., row id = 2
in the example above)?
Upvotes: 1
Views: 37
Reputation:
Just compare it with a reference:
select *
from foobar
where data = '[[true, true], [true, true]]'
Upvotes: 1