Looking for a way to check if one of the items of given array exists in db property, which is also an array. I have a table 'Events', which has a property weekDays, which is an array of numbers [1,2,3,4,5]. Given an array searchDays which is [2,3], I want to check if the one of the items exists in weekDays.
2 Answers
you are looking for intersecion I suppose:
t=# with c(weekdays,searchdays) as (values(array[1,2,3,4,5],array[2,3]))
select weekdays && searchdays from c;
?column?
----------
t
(1 row)