What would be the correct syntax in Postgres to do something like:
SELECT ARRAY[4,5,6] IN ARRAY[[4,5,6],[7,8,9]];
Some dbs have a list_contains
or IN UNNEST(arr_expr)
to do something like the above but I haven’t been having luck checking in Postgres docs.
2
Answers
If your containing array has sub-arrays all the same length you should be able to use the array-contains operator
However, be aware it is more "generous" in its matching than you might want
See the manuals for details.
UNNEST
"flattens" multidimensional arrays, so it is not useful herearray-contains (
<@
operator) also internally "flattens" such arraysYou can try to store your data as
JSON(B)
and it will work as expected: