I have a ids integer[]
And, I want to find rows which contain 1 but must not contains 2, 3, 4
but [1] OR [1, 5] OR [1, 6, 7] <- this data is OK. [2,3,4] is not.
So I tried this way
SELECT *
FROM table_test
WHERE 1 = ANY(ids) AND 2 <> ANY(ids) AND 3 <> ANY(ids) AND 4 <> ANY(ids)
but it returns 1 = ANY(ids) part
[1 2 3]
[1 3 4]
[1]
[1 5]
[1 6 7]
I want this data
[1]
[1 5]
[1 6 7]
How can I solve this problem?
Thanks a lot!