I'm trying to solve exactly this: How to check if a cell of type integer array contains a certain value in SQL but for multiple values on boths sides
so something like this:
SELECT id FROM table WHERE ALL(column_of_type_integer_array) IN (2,3,4)
Is there anything like this or do I have to split my values up?
table callenges
id| precoditions
-----------------
1 |[]
2 |[]
3 |[]
4 |[2,3]
So I only want to select chalenges where the precodition challenges are fullfilled.
SELECT id FROM callenges WHERE All(preconditions) IN ${solvedChallenges}
Use the operator <@
- is contained by, e.g.:
with my_table(arr) as (
values
(array[2,3,4,2,3]),
(array[1,2,3,4,2,3])
)
select *
from my_table
where arr <@ array[2,3,4]
arr
-------------
{2,3,4,2,3}
(1 row)