0

In the following example the column parents is an array of int (parents INT[]).

If I want to select all rows in which the array of parents contains 42, I can run this query:

SELECT * FROM records WHERE 42 = ANY (parents);

Now I want to do the opposite and select each row in which parents does not contain 42.

I tried this:

SELECT * FROM records WHERE 42 != ANY (parents);

without luck... Does anyone know how this can be done?

I'm using Postgresql 10.3.

1
  • 2
    42 <> ALL(parents) Commented Apr 13, 2018 at 10:30

2 Answers 2

3
SELECT * FROM records WHERE NOT (42 = ANY (parents))

Demo

http://sqlfiddle.com/#!17/394c0/1

Sign up to request clarification or add additional context in comments.

Comments

0

check example. Reference -> Refrence link

SELECT value_variable = ANY ('{1,2,3}'::int[])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.